JavaScript Math.clz32()
Example
let a = Math.clz32(0);
let b = Math.clz32(1);
let c = Math.clz32(2);
let d = Math.clz32(4);
Try it Yourself »
Definition and Usage
The Math.clz32()
method returns the number of leading zeros in a 32-bit binary number.
clz32 is short for CountLeadingZeroes32.
Syntax
Math.clz32(x)
Parameters
Parameter | Description |
x | Required. A number. |
Return Value
Type | Description |
Number | Number of leading zeros in the 32-bit binary representation of a number. If the number is 0, it returns 32 (all bits are 0). |
Browser Support
Math.clz32()
is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Math.clz32()
is not supported in Internet Explorer 11 (or earlier).