- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use of Math.clz32() method in JavaScript?
Math.clz32()
The Math.clz32() function returns the number of leading zero bits in the 32-bit binary representation of a number. In a binary representation, there are 32 numbers consisting of only 1's and 0's. This method scrutinizes through each and every element and returns the number of 0's.
syntax
Math.clz32(number);
Example-1
In the following example, numbers 1 and 0 were passed into the Math.Clz32() function and the number of trailing zeroes were displayed in the output.
<html> <body> <script> document.write(Math.clz32(1)); document.write("</br>"); document.write(Math.clz32(0)); </script> </body> </html>
Output
31 32
Example-2
In the following example, numbers 21 and 20 were passed into the Math.Clz32() function and the number of trailing zeroes(27, 27) were displayed in the output.
<html> <body> <script> document.write(Math.clz32(21)); document.write("</br>") document.write(Math.clz32(20)) </script> </body> </html>
Output
27 27
Advertisements