blob: 191a87c50492feefce219854c4edf3e7d23c8c26 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
.TH ZBITS 3 libzahl
.SH NAME
zbits - Count used bits in a big integer
.SH SYNOPSIS
.nf
#include <zahl.h>
size_t zbits(z_t \fIa\fP);
.fi
.SH DESCRIPTION
.B zbits
calculates the bit-size of
.IR a .
If
.I a
is zero the bit-size is 1.
.SH RETURN VALUE
.B zbits
returns the number of bits requires
to represent
.I a
\(em 1 plus the floored binary logarithm of the
absolute value of
.I a
\(em or 1 if
.I a
is zero.
.SH RATIONALE
.B zbits
returns 1 rather than 0 if
.B a
is zero, this is to avoid off-by-one errors
and it is the number of digits requires to
write the number in binary. You will see this
in corresponding functions in other libraries.
.SH SEE ALSO
.BR zlsb (3),
.BR zzero (3)
|