TOPICS
Search

Bit Length


BitLength

The bit length BL(n) of a positive integer n is the number of binary digits in its representation without leading zeros. It is given by

BL(n)=1+|_lgn_|
(1)
=[lg(n+1)],
(2)

where [x] is the ceiling function, |_x_| is the floor function, and lgn denotes the binary logarithm (see lg). Adopt BL(0)=0 by convention. For n=0, 1, 2, ..., the sequence of bit lengths is given by 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, ... (OEIS A029837, with BL(n)=a(n+1)). The function is given by the Wolfram Language function BitLength[n].


See also

Bit Complexity

Explore with Wolfram|Alpha

References

Sloane, N. J. A. Sequence A029837 in "The On-Line Encyclopedia of Integer Sequences."

Referenced on Wolfram|Alpha

Bit Length

Cite this as:

Weisstein, Eric W. "Bit Length." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/BitLength.html

Subject classifications