Skip to main content

Mojo function

mulhi

mulhi(a: UInt16, b: UInt16) -> UInt32

Calculates the most significant 32 bits of the product of two 16-bit unsigned integers.

Multiplies two 16-bit unsigned integers and returns the high 32 bits of their product. Useful for fixed-point arithmetic and overflow detection.

Note: On NVIDIA GPUs, this maps directly to the MULHI.U16 PTX instruction. On others, it performs multiplication using 32-bit arithmetic.

Args:

  • a (UInt16): First 16-bit unsigned integer operand.
  • b (UInt16): Second 16-bit unsigned integer operand.

Returns:

UInt32: The high 32 bits of the product a * b

mulhi(a: Int16, b: Int16) -> Int32

Calculates the most significant 32 bits of the product of two 16-bit signed integers.

Multiplies two 16-bit signed integers and returns the high 32 bits of their product. Useful for fixed-point arithmetic and overflow detection.

Note: On NVIDIA GPUs, this maps directly to the MULHI.S16 PTX instruction. On others, it performs multiplication using 32-bit arithmetic.

Args:

  • a (Int16): First 16-bit signed integer operand.
  • b (Int16): Second 16-bit signed integer operand.

Returns:

Int32: The high 32 bits of the product a * b

mulhi(a: UInt32, b: UInt32) -> UInt32

Calculates the most significant 32 bits of the product of two 32-bit unsigned integers.

Multiplies two 32-bit unsigned integers and returns the high 32 bits of their product. Useful for fixed-point arithmetic and overflow detection.

Note: On NVIDIA GPUs, this maps directly to the MULHI.U32 PTX instruction. On others, it performs multiplication using 64-bit arithmetic.

Args:

  • a (UInt32): First 32-bit unsigned integer operand.
  • b (UInt32): Second 32-bit unsigned integer operand.

Returns:

UInt32: The high 32 bits of the product a * b

mulhi(a: Int32, b: Int32) -> Int32

Calculates the most significant 32 bits of the product of two 32-bit signed integers.

Multiplies two 32-bit signed integers and returns the high 32 bits of their product. Useful for fixed-point arithmetic and overflow detection.

Note: On NVIDIA GPUs, this maps directly to the MULHI.S32 PTX instruction. On others, it performs multiplication using 64-bit arithmetic.

Args:

  • a (Int32): First 32-bit signed integer operand.
  • b (Int32): Second 32-bit signed integer operand.

Returns:

Int32: The high 32 bits of the product a * b

mulhi(a: UInt64, b: UInt64) -> UInt64

Calculates the most significant 64 bits of the product of two 64-bit unsigned integers.

Multiplies two 64-bit unsigned integers and returns the high 64 bits of their product. Useful for fixed-point arithmetic and overflow detection.

Note: On NVIDIA GPUs, this maps directly to the MULHI.U64 PTX instruction. On others, it performs multiplication using 128-bit arithmetic.

Args:

  • a (UInt64): First 64-bit unsigned integer operand.
  • b (UInt64): Second 64-bit unsigned integer operand.

Returns:

UInt64: The high 64 bits of the product a * b.

mulhi(a: Int64, b: Int64) -> Int64

Calculates the most significant 64 bits of the product of two 64-bit signed integers.

Multiplies two 64-bit signed integers and returns the high 64 bits of their product. Useful for fixed-point arithmetic and overflow detection.

Note: On NVIDIA GPUs, this maps directly to the MULHI.S64 PTX instruction. On others, it performs multiplication using 128-bit arithmetic.

Args:

  • a (Int64): First 64-bit signed integer operand.
  • b (Int64): Second 64-bit signed integer operand.

Returns:

Int64: The high 64 bits of the product a * b.

Was this page helpful?