Speed up development with full-stack environments for every branch.Learn More
Calculate the hamming distance between two GMP numbers [PHP]
9 Runs 27 Views 2 Copies
<?php /* * PHP GMP - Calculate the hamming distance between two GMP numbers */ $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"; ?>
Please login/signup to get access to the terminal.