JavaScript clz32() Method
Example
Return the number of leading zeros in a 32-bit binary representation of
different numbers:
var a = Math.clz32(0);
var b = Math.clz32(1);
var
c = Math.clz32(2);
var d = Math.clz32(4);
Try it Yourself »
Definition and Usage
The clz32()
method is short for CountLeadingZeroes32, and it returns the number of leading zeros in a 32-bit binary representation of a number.
Browser Support
Method |
|
|
|
|
|
clz32() |
38.0 |
12.0 |
31.0 |
7.0 |
25.0 |
Syntax
Parameter Values
Parameter |
Description |
x |
Required. A number |
Technical Details
Return Value: |
The number of leading zeros bits in the 32-bit
binary representation of a number. If the number is 0, then this method
returns 32 (as all bits are 0). |
JavaScript Version: |
ECMAScript 2015 |