bitLength

bitLength

> Functions

Returns the number of significant bits needed to represent the number x*, that is, the position of the highest bit at 1, plus one. Returns 0 when *x is 0.

For a positive number, the result is equal to floor(log2(x)) + 1. The function also works on big integers.

A negative integer returns 64, since its sign bit is at 1. For a negative big integer, the sign bit is not counted: bitLength(-1L) returns 0 and bitLength(-8L) returns 3.

Parameters
Return
Note