JavaScript clz32() Method

Definition and Usage

clz32() The method is an abbreviation of CountLeadingZeroes32, which returns the number of leading zeros in the 32-bit binary representation of a number.

Example

Returns the number of leading zeros in the 32-bit binary representation of different numbers:

var a = Math.clz32(0);
var b = Math.clz32(1);
var c = Math.clz32(2);
var d = Math.clz32(4);

Try It Yourself

Syntax

Math.clz32(x)

Parameter Value

Parameter Description
x Required. Number.

Technical Details

Return value:

The number of leading zeros in the 32-bit binary representation of the number.

If the number is 0, this method returns 32 (because all bits are 0).

JavaScript Version: ECMAScript 2015

Browser Support

Method Chrome Edge Firefox Safari Opera
clz32() 38.0 12.0 31.0 7.0 25.0

Related Pages

Tutorial:JavaScript Math