gmp_hamdist

(PHP 4 >= 4.0.4, PHP 5, PHP 7)

gmp_hamdistHamming distance

说锟斤拷

gmp_hamdist ( GMP $a , GMP $b ) : int

Returns the hamming distance between a and b. Both operands should be non-negative.

锟斤拷锟斤拷

a

锟斤拷锟斤拷锟斤拷一锟斤拷 GMP 锟斤拷锟斤拷 resouce锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷转锟斤拷为锟斤拷值锟斤拷锟街凤拷锟斤拷锟斤拷

It should be positive.

b

锟斤拷锟斤拷锟斤拷一锟斤拷 GMP 锟斤拷锟斤拷 resouce锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷转锟斤拷为锟斤拷值锟斤拷锟街凤拷锟斤拷锟斤拷

It should be positive.

锟斤拷锟斤拷值

GMP 锟斤拷值锟斤拷源.

锟斤拷锟斤拷

Example #1 gmp_hamdist() 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

锟轿硷拷