IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

mulhi

def 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: The product is computed in 64-bit arithmetic, which NVIDIA GPUs compile to a single mul.hi.u32 instruction.

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

def 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: The product is computed in 64-bit arithmetic, which NVIDIA GPUs compile to a single mul.hi.s32 instruction.

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

def 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: The product is computed in 128-bit arithmetic, which NVIDIA GPUs compile to a single mul.hi.u64 instruction.

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.

def 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: The product is computed in 128-bit arithmetic, which NVIDIA GPUs compile to a single mul.hi.s64 instruction.

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.