![]() |
|
|
+ Search |
![]()
|
Mar 25th, 2000 16:26
Martin Honnen,
The following function calls toString(2) to convert to binary notation
and then takes the length:
function bitLength (n) {
return n.toString(2).length;
}
Examples:
alert(bitLength(2))
alert(bitLength(16))