Math.imul( )
Unlike other multiplying functions, the Math.imul() function returns the result of the C-like 32-bit multiplication of the two parameters. Its application is very high in projects like Emscripten.
syntax
var product = Math.imul(a, b);
This method takes two numbers and gives out their multiplication value.
Example-1
In the following example, two normal integers were given as parameters to the method Math.Imul() and the obtained result is displayed as shown in the output.
<html>
<body>
<script>
document.write(Math.imul(3, 4));
document.write("</br>");
document.write(Math.imul(-3, 4));
</script>
</body>
</html>Output
12 -12
Example-2
In the following example, c-like 32-bit values were given as parameters to the method Math.Imul() and the obtained result is displayed as shown in the output
<html>
<body>
<script>
document.write(Math.imul(0xffffffff, 4));
document.write("</br>");
document.write(Math.imul(0xfffffffe, 4));
</script>
</body>
</html>Output
-4 -8