Math
is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains a clz32()
function, which is used to compute the number of leading zeros in a 32-bit binary representation of a specified number. clz
stands for count leading zeros.
Math.clz32(param);
param
: This is the input value of the Number
type for which we want to find the clz32()
.
Number
in JavaScript is a 64-bit double-precision value that is the same asdouble
in C# or Java.
If
param
is not a number, it will be converted to a number first, then converted to a 32-bit unsigned integer.
Number
: It returns a count of leading zeros when param
is represented in a 32-bit representation. It is of the Number
type.console.log("clz32(-20) = " + Math.clz32(-20));console.log("clz32(20) = " + Math.clz32(20));console.log("clz32(0) = " + Math.clz32(0));console.log("clz32(2.34) = " + Math.clz32(2.34));console.log("clz32(-2.34) = " + Math.clz32(-2.34));