Math.clz32
clz32 — Returns the number of leading zero bits in the 32-bit binary representation of a number.
Description
Math.clz32(number number)
Parameters
Name |
Description |
Type |
Default |
Optional |
number |
|
number |
|
No |
Examples
Example #1 – clz32 example
console.log(Math.clz32(1)); // 31
console.log(Math.clz32(1.5)); // 31
console.log(Math.clz32(2)); // 30
console.log(Math.clz32(3)); // 30
console.log(Math.clz32(4)); // 29
console.log(Math.clz32(7)); // 29
console.log(Math.clz32(8)); // 28
console.log(Math.clz32(4095)); // 20
console.log(Math.clz32(4096)); // 19
console.log(Math.clz32(-10)); // 0
External references