mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
30 lines
593 B
Plaintext
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
|