php-doc-en/reference/gmp/functions/gmp-hamdist.xml
2004-02-26 11:14:11 +00:00

70 lines
1.8 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/gmp.xml, last change in rev 1.1 -->
<refentry id="function.gmp-hamdist">
<refnamediv>
<refname>gmp_hamdist</refname>
<refpurpose>Hamming distance</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>gmp_hamdist</methodname>
<methodparam><type>resource</type><parameter>a</parameter></methodparam>
<methodparam><type>resource</type><parameter>b</parameter></methodparam>
</methodsynopsis>
<para>
Returns the hamming distance between <parameter>a</parameter> and
<parameter>b</parameter>. Both operands should be non-negative.
</para>
<example>
<title><function>gmp_hamdist</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$ham1 = gmp_init("1001010011", 2);
$ham2 = gmp_init("1011111100", 2);
echo gmp_hamdist($ham1, $ham2) . "\n";
/* hamdist is equivilent to: */
echo gmp_popcount(gmp_xor($ham1, $ham2)) . "\n";
?>
]]>
</programlisting>
<para>
The printout of the above program will be:
</para>
<screen>
<![CDATA[
6
6
]]>
</screen>
</example>
<para>
See also <function>gmp_popcount</function>,
<function>gmp_xor</function>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->