Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน gmp_hamdist() ใน PHP


ฟังก์ชัน gmp_hamdist() คำนวณ Hamming Distance ระหว่างจำนวน GMP 2 ตัว (จำนวนบิตที่ต่างกัน)

ไวยากรณ์

gmp_hamdist(n1, n2)

พารามิเตอร์

  • n1: จำนวน GMP ตัวแรก (object หรือ numeric string)
  • n2: จำนวน GMP ตัวที่สอง

คืนค่า

GMP number คือ Hamming distance

ตัวอย่าง

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

ผลลัพธ์

0