bitLength property

int bitLength

Returns the minimum number of bits required to store this integer.

The number of bits excludes the sign bit, which gives the natural length for non-negative (unsigned) values. Negative values are complemented to return the bit position of the first bit that differs from the sign bit.

To find the the number of bits needed to store the value as a signed value, add one, i.e. use x.bitLength + 1.


int get bitLength;