PHP.nl

gmp_popcount

gmp_popcount

Population count

int **gmp_popcount**  $num

Get the population count.

num

The population count of , as an . num``int

Voorbeeld: example

<?php
$pop1 = gmp_init("10000101", 2); // 3 1's
echo gmp_popcount($pop1) . "\n";
$pop2 = gmp_init("11111110", 2); // 7 1's
echo gmp_popcount($pop2) . "\n";
?>
3
7