Returns the parity of an integer’s binary representation (i.e., the parity of the number of bits set).
Fortran 2008 and later
result = poppar(i)
i
- Shall be of type integer
.The return value is of type ‘integer’ and of the default integer kind. It is equal to 0 if i
has an even number of bits set and 1 if an odd number of bits are set.
program test_population
print *, popcnt(127), poppar(127)
print *, popcnt(huge(0_4)), poppar(huge(0_4))
print *, popcnt(huge(0_8)), poppar(huge(0_8))
end program test_population