Clicky

Fortran Wiki
poppar

Description

Returns the parity of an integer’s binary representation (i.e., the parity of the number of bits set).

Standard

Fortran 2008 and later

Class

Elemental function

Syntax

result = poppar(i)

Arguments

  • i - Shall be of type integer.

Return value

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.

Example

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

See Also

popcnt, leadz, trailz

category: intrinsics