What is Math.imul() in JavaScript?

Math is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains the imul() function, which is used to compute 32-bit integer multiplication of two specified values.

Syntax

Math.imul(param1, param2);

Parameter

  • param1: This is the first input value of Number type for which we want to find the imul().

  • param2: This is the second input value of Number type for which we want to find the imul().

Return value

  • Number: It returns the 32-bit integer multiplication of the two parameters param1 and param2.

If Number is not an integer, it is first converted into an integer.

Example

console.log("imul(2,4) = " + Math.imul(2,4));
console.log("imul(-10,10) = " + Math.imul(-10,-10));
console.log("imul(0,4) = " + Math.imul(0,4));
console.log("imul(3.34,4.2) = " + Math.imul(3.34,4.2));
console.log("imul(-0.15,-4.11) = " + Math.imul(-0.15,-4.11));

Free Resources