array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'function.gmp-popcount.php', 1 => 'gmp_popcount', ), 'up' => array ( 0 => 'ref.gmp.php', 1 => 'GMP Funktionen', ), 'prev' => array ( 0 => 'function.gmp-perfect-square.php', 1 => 'gmp_perfect_square', ), 'next' => array ( 0 => 'function.gmp-pow.php', 1 => 'gmp_pow', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/gmp/functions/gmp-popcount.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
gmp_popcount — Population count
The population count of num
, as an int.
Beispiel #1 gmp_popcount() 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";
?>
Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
3 7