Computer >> Computer tutorials >  >> Programming >> PHP

gmp_hamdist() function in PHP


The gmp_hamdist() function is used to get the hamming distance between two GMP numbers.

Syntax

gmp_hamdist ( n1, n2)

Parameters

  • n1 − The first GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.

  • n2 − The second GMP number. It can be GMP object in PHP version 5.6 and later. Can also be numeric strings.

Return

The gmp_hamdist() function returns the GMP number as the hamming distance.

Example

The following is an example −

<?php
   $n1 = "5";
   $n2 = "5";
   $dist = gmp_hamdist($n1, $n2);
   echo $dist;
?>

Output

The following is the output −

0