bitlengthn
Bitlength(n) is the minimal number of binary digits required to represent the integer n in binary form. For a nonzero integer n, bitlength(n) equals floor(log2(|n|)) + 1, i.e., the position of the most significant 1 bit plus one. This definition applies to unsigned integers; when n is signed, bitlength typically refers to the magnitude's bitlength, independent of sign.
For n = 0, conventions vary: many programming languages define bitlength(0) as 0, while some mathematical treatments
Bitlength is different from a fixed word size or bit width used by hardware, which represents the
Applications include algorithm design and analysis, where running time or space depends on the bitlength of