Home » JavaScript Tutorial

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

Parameter(s):

  • 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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.