array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'pt_BR', ), 'this' => array ( 0 => 'function.gmp-hamdist.php', 1 => 'gmp_hamdist', ), 'up' => array ( 0 => 'ref.gmp.php', 1 => 'Funções GMP', ), 'prev' => array ( 0 => 'function.gmp-gcdext.php', 1 => 'gmp_gcdext', ), 'next' => array ( 0 => 'function.gmp-import.php', 1 => 'gmp_import', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'pt_BR', 'path' => 'reference/gmp/functions/gmp-hamdist.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_hamdist — Distância de Hamming
Retorna a distância de Hamming entre num1
e
num2
. Ambos argumentos devem ser positivos.
A distância de Hamming entre num1
e num2
, do tipo int.
Exemplo #1 Exemplo de gmp_hamdist()
<?php
$ham1 = gmp_init("1001010011", 2);
$ham2 = gmp_init("1011111100", 2);
echo gmp_hamdist($ham1, $ham2) . "\n";
/* a distância de Hamming é equivalente a : */
echo gmp_popcount(gmp_xor($ham1, $ham2)) . "\n";
?>
O exemplo acima produzirá:
6 6