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 ofNumbertype for which we want to find theimul(). -
param2: This is the second input value ofNumbertype for which we want to find theimul().
Return value
Number: It returns the 32-bit integer multiplication of the two parametersparam1andparam2.
If
Numberis 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));