2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. index:: POPCNT, binary representation, bits set
10 POPCNT --- Number of bits set
11 *****************************
13 .. function:: POPCNT(I)
15 ``POPCNT(I)`` returns the number of bits set ('1' bits) in the binary
16 representation of ``I``.
19 Shall be of type ``INTEGER``.
22 The return value is of type ``INTEGER`` and of the default integer
26 Fortran 2008 and later
32 .. code-block:: fortran
37 .. code-block:: fortran
39 program test_population
40 print *, popcnt(127), poppar(127)
41 print *, popcnt(huge(0_4)), poppar(huge(0_4))
42 print *, popcnt(huge(0_8)), poppar(huge(0_8))
43 end program test_population