
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Use of Math.imul Function in JavaScript
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
Advertisements