GMP gmp_popcount
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
gmp_popcount — Population count
설명
gmp_popcount(GMP|int|string $num
): int
Get the population count.
매개변수
num
- GMP 개체, int 또는 숫자 문자열입니다.
반환 값
The population count of num, as an int.
Examples
예제 #1 gmp_popcount() 예제
<?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