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

Was this page helpful?