Purpose
Population count
Counts
the number of set bits in a data object.
Argument type and attributes
- I
- An INTENT(IN) argument of type integer
- The argument can also be of type byte, logical,
or real. If the type of the argument is real, it must not be REAL(16).
Result type and attributes
Default
integer
Result value
The number of bits
set to 1 in the sequence of bits of I
Examples
The following table
shows the functionality of the POPCNT function.
Integer |
Bit Representation |
POPCNT |
0 |
0000 |
0 |
1 |
0001 |
1 |
2 |
0010 |
1 |
3 |
0011 |
2 |
4 |
0100 |
1 |