let a = Math.clz32(0);
let b = Math.clz32(1);
let c = Math.clz32(2);
let d = Math.clz32(4);
Try it Yourself »
The Math.clz32()
method returns the number of leading zeros in a 32-bit binary number.
clz32 is short for CountLeadingZeroes32.
Math.clz32(
x)
Parameter | Description |
x | Required. A number. |
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). |
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).
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!