Home »
JavaScript
Math.imul() Method with Example in JavaScript
JavaScript | Math.imul() Method: Here, we are going to learn about the imul() method of Math class in JavaScript with Examples.
Submitted by Shivang Yadav, on February 03, 2020
JavaScript | Math.imul() Method
Math.imul() is a function in math library of JavaScript that is used to the 32-bit multiplication of the two values passed to it. It uses C-like semantics to find the multiplication. It can accept floating-point variables but will convert it into integer before conversion.
Syntax
Math.imul(val1, val2);
Parameters
- val1, val2 – represent the values that are to be multiplied using 32-bit multiplication.
Return Value
The return type of this method is number, it returns the 32-bit multiplication.
Browser support: Chrome, Internet explorer, Mozilla, Safari, Opera mini.
Example 1: Valid values
console.log(Math.imul(8, 5));
console.log(Math.imul(6.4, 2.1));
console.log(Math.imul(-32, 32));
console.log(Math.imul(0, 23));
console.log(Math.imul("27.08", "-3"));
Output
40
12
-1024
0
-81
Example 2: With strings
console.log(Math.imul("Javascript"));
console.log(Math.imul("Javascript", "C++"));
Output
0
0
JavaScript Math Object Methods »