JS Built-ins
← Math92 / 215
Mathclz32intermediate

Math.clz32(2) Equals 30

πŸ“– Usage Example
// Count leading zero bits in a 32-bit integer
Math.clz32(1)   // β†’ 31
Math.clz32(4)   // β†’ 29

Use Math.clz32() to count leading zero bits of a 32-bit integer, useful in low-level bitwise optimizations.

Math.clz32(x)

Math.clz32(2) returns 30 because 2 in 32-bit binary is 00000000000000000000000000000010.

Challenge: Verify the leading zero count for 2.

πŸ’‘ Hints (2)
  • β€’ Each power of 2 reduces the leading zero count by 1
  • β€’ clz32(2) = clz32(1) - 1 = 30