Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_popcount

Description

The gmp_popcount of GMP for PHP population count.

Syntax

gmp_popcount(
    GMP|int|string $num
): int

Parameters

num

A GMP object, an int or a numeric string.

Return

Returns the population count of num, as an int.

Total count of 1's in binary.

Examples

1 · num · GMP

<?

$num = 0b101;

$num = gmp_init($num);

$return = gmp_popcount($num);

echo $return;

?>
2

2 · num · int

<?

$num = 0b101;

$return = gmp_popcount($num);

echo $return;

?>
2

3 · num · string

<?

$num = "0b101";

$return = gmp_popcount($num);

echo $return;

?>
2
HomeMenu