GMP gmp_hamdist
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
gmp_hamdist — 해밍 거리
설명
gmp_hamdist(GMP|int|string $num1
, GMP|int|string $num2
): int
num1
과 num2
사이의 해밍 거리를 반환합니다. 두 피연산자는 모두 음수가 아니어야 합니다.
매개변수
반환 값
num1
과 num2
사이의 해밍 거리(int)입니다.
Examples
예제 #1 gmp_hamdist() 예제
<?php
$ham1 = gmp_init("1001010011", 2);
$ham2 = gmp_init("1011111100", 2);
echo gmp_hamdist($ham1, $ham2) . "\n";
/* hamdist is equivalent to: */
echo gmp_popcount(gmp_xor($ham1, $ham2)) . "\n";
?>
위의 예는 다음을 출력합니다.
6 6
기타
- gmp_popcount() - Population count
- gmp_xor() - Bitwise XOR