Thursday, November 13, 2025
HomeLanguagesJavascriptJavaScript Math.clz32() Function

JavaScript Math.clz32() Function

The Math.clz32( ) function in JavaScript returns the number of leading zero bits in the 32-bit binary representation of a number. Clz32 stands for Count Leading Zeros 32. If the passed parameter is not a number, then it will be converted into a number first and then converted to a 32-bit unsigned integer. If the converted 32-bit unsigned integer is 0, then the function returns 32, since all the bits are 0.

 Syntax:

Math.clz32(number)

Parameters Used: number: It is the value that is to be tested for CountLeadingZeros. 

Return Value: It returns the number of leading zero bits in the 32-bit binary representation of the given number.

Example 1: When a positive number is passed as a parameter. 

Javascript




<script type="text/javascript">
        console.log("Output : " + Math.clz32(5));        
    </script>


Output:

Output : 29

Example 2: When a negative number is passed as a parameter. 

Javascript




<script type="text/javascript">
        console.log("Output : " + Math.clz32(-5));        
    </script>


Output:

Output : 0

Example 3: When zero is passed as a parameter. 

Javascript




<script type="text/javascript">
        document.write("Output : " + Math.clz32(0));        
    </script>


Output:

Output : 32

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
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11916 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11983 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7141 POSTS0 COMMENTS
Thapelo Manthata
6835 POSTS0 COMMENTS
Umr Jansen
6838 POSTS0 COMMENTS