text: Hamming distance between two Integers | Function to calculate hamming distance ; Driver code
code: < ? php function hammingDistance ( $ n1 , $ n2 ) { $ x = $ n1 ^ $ n2 ; $ setBits = 0 ; while ( $ x > 0 ) { $ setBits += $ x & 1 ; $ x >>= 1 ; } return $ setBits ; } $ n1 = 9 ; $ n2 = 14 ; echo ( hammingDistance ( 9 , 14 ) ) ; ? >