Saturday, August 30, 2025
HomeLanguagesJavascriptJavaScript Math imul() Method

JavaScript Math imul() Method

The Javascript Math.imul() method in JavaScript is used to calculate the result of the 32-bit multiplication of the two integers passed as parameters to it. Math.imul() allows for 32-bit integer multiplication with C-like semantics. If the Math.imul() method is used with normal floating type variables in JavaScript then there will be a degradation in performance because of the conversion of floats to ints before multiplication. The overhead of conversion results in a performance degrades if the Math.imul() method is used with normal floating-point variables allowed in JavaScript.

Syntax:

Math.imul(Value1, Value2);

Parameters: This method accepts two parameters 

  • Value1, Value2: Which represents two numbers to be multiplied. 

Return Value: The Math.imul() method returns the result of the C-like 32-bit multiplication of the given arguments.

Below programs illustrate the Math.imul() method in JavaScript:

Example 1: When two positive numbers are passed as parameters. 

Javascript




console.log(Math.imul(3, 4));


Output

12

Example 2: When both the numbers(of opposite sign) are passed as parameters. 

Javascript




console.log(Math.imul(0xfffffffe, 4));


Output

-8

Example 3: When two negative numbers are passed as parameters. 

Javascript




console.log(Math.imul(-3, -4));


Output

12

Example 4: When one of the parameters passed is a zero. 

Javascript




console.log(Math.imul(0, 4));


Output

0

We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.

Supported Browsers:

  • Google Chrome 1 and above
  • Internet Explorer 3 and above
  • Firefox 1 and above
  • Opera 3 and above
  • Safari 1 and above
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32249 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6617 POSTS0 COMMENTS
Nicole Veronica
11792 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11839 POSTS0 COMMENTS
Shaida Kate Naidoo
6732 POSTS0 COMMENTS
Ted Musemwa
7014 POSTS0 COMMENTS
Thapelo Manthata
6689 POSTS0 COMMENTS
Umr Jansen
6703 POSTS0 COMMENTS