next up previous contents index
suivant: Strings monter: Operators bit to bit précédent: Operators bitor, bitxor, bitand   Table des matières   Index


Hamming distance bit to bit : hamdist

The Hamming distance is the number of differences of the bits of the two arguments.
Input :
hamdist(0x12,0x38)
or input
ha mdist(18,56)
Output :
3
because :
18 is written 0x12 in base 16 and 0b010010 in base 2,
56 is written 0x38 in base 16 and 0b111000 in base 2,
hamdist(18,56) is equal to 1+0+1+0+1+0 and so is equal to 3.



giac documentation written by Renée De Graeve and Bernard Parisse