A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-math-imul-method/ below:

JavaScript Math imul() Method - GeeksforGeeks

JavaScript Math imul() Method

Last Updated : 12 Jul, 2024

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 

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));

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

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

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

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

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

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

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:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4