Initial revision
[LeanCalc.git] / help / popcnt
1 NAME
2     popcnt - number of bit that match a given value
3
4 SYNOPSIS
5     popcnt(x [,bitval])
6
7 TYPES
8     x           number (real or integer)
9     bitval      0 or 1
10
11     return      number
12
13 DESCRIPTION
14     Count the number of bits in abs(x) that match bitval.  The default
15     bitval is 1 which counts the number of 1 bits.
16
17     The popcnt function is equivalent to #x when x is an integer.
18
19 EXAMPLE
20     > print popcnt(32767), popcnt(3/2), popcnt(pi(),0), popcnt(pi(),1)
21     15 3 69 65
22
23     > print popcnt(randombit(128), 0), popcnt(randombit(128), 1)
24     61 64
25
26 LIMITS
27     none
28
29 LINK LIBRARY
30     long zpopcnt(ZVALUE z, int bitval)
31
32 SEE ALSO
33     none
34