gmp_hamdist
gmp_hamdist
Hamming distance
int **gmp_hamdist** $num1 $num2
Returns the hamming distance between and
. Both operands should be non-negative.
num1``num2
num1It should be positive.
num2It should be positive.
The hamming distance between and , as an .
num1``num2``int
Voorbeeld: example
<?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``gmp_xor