Files
calc/help/highbit
2017-05-21 15:38:33 -07:00

30 lines
593 B
Plaintext

NAME
highbit - index of highest bit in binary representation of integer
SYNOPSIS
highbit(x)
TYPES
x nonzero integer
return integer
DESCRIPTION
If x is a nonzero integer, highbit(x) returns the index of the
highest bit in the binary representation of abs(x). Equivalently,
highbit(x) = n if 2^n <= abs(x) < 2^(n + 1); the binary
representation of x then has n + 1 digits.
EXAMPLE
> print highbit(2), highbit(3), highbit(4), highbit(-15), highbit(2^27)
1 1 2 3 27
LIMITS
none
LIBRARY
LEN zhighbit(ZVALUE x);
SEE ALSO
lowbit, digits