The gmp_popcount() function gets the count of set bits in the binary representation of a GMP number.
Syntax
gmp_popcount (val)
Parameters
val: The GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.
Return
The gmp_popcount() function returns the number of set bits in binary representation of a GMP number. The result is an integer.
Example
The following is an example:
<?php $val= "6"; $res = gmp_popcount($val); echo $res; ?>
Output
The following is the output:
2