Module malachite_base::num::logic::hamming_distance
source · Expand description
HammingDistance
and
CheckedHammingDistance
, traits for computing the Hamming
distance between two numbers.
§hamming_distance
use malachite_base::num::logic::traits::HammingDistance;
assert_eq!(123u32.hamming_distance(456), 6);
assert_eq!(0u8.hamming_distance(255), 8);
§checked_hamming_distance
use malachite_base::num::logic::traits::CheckedHammingDistance;
assert_eq!(123i32.checked_hamming_distance(456), Some(6));
assert_eq!(0i8.checked_hamming_distance(127), Some(7));
assert_eq!(0i8.checked_hamming_distance(-1), None);