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 »
Description
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 since June 2017:
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |
Math.clz32()
is not supported in Internet Explorer.