Skip to main content
Version: 3.27.2

Math.imul()

The Math.imul() function returns the result of the C-like 32-bit multiplication of the two parameters.

Syntax

Math.imul(a, b)

Parameters

  • a
    • : First number.
  • b
    • : Second number.

Return value

The result of the C-like 32-bit multiplication of the given arguments.

Description

Math.imul() allows for 32-bit integer multiplication with C-like semantics. This feature is useful for projects like Emscripten.

Because imul() is a static method of Math, you always use it as Math.imul(), rather than as a method of a Math object you created (Math is not a constructor).

If you use normal JavaScript floating point numbers in imul(), you will experience a degrade in performance. This is because of the costly conversion from a floating point to an integer for multiplication, and then converting the multiplied integer back into a floating point.