Trait malachite_base::num::logic::traits::CheckedHammingDistance
source · [−]pub trait CheckedHammingDistance<RHS = Self> {
fn checked_hamming_distance(self, other: RHS) -> Option<u64>;
}
Expand description
Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.
This trait allows for the possibility of the distance being undefined for some pairs of
numbers, in which case checked_hamming_distance
should
return None
.
Required Methods
fn checked_hamming_distance(self, other: RHS) -> Option<u64>
Implementations on Foreign Types
sourceimpl CheckedHammingDistance<i8> for i8
impl CheckedHammingDistance<i8> for i8
sourcefn checked_hamming_distance(self, other: i8) -> Option<u64>
fn checked_hamming_distance(self, other: i8) -> Option<u64>
Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.
If the two numbers have opposite signs, then the number of flips would be infinite,
so the result is None
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl CheckedHammingDistance<i16> for i16
impl CheckedHammingDistance<i16> for i16
sourcefn checked_hamming_distance(self, other: i16) -> Option<u64>
fn checked_hamming_distance(self, other: i16) -> Option<u64>
Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.
If the two numbers have opposite signs, then the number of flips would be infinite,
so the result is None
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl CheckedHammingDistance<i32> for i32
impl CheckedHammingDistance<i32> for i32
sourcefn checked_hamming_distance(self, other: i32) -> Option<u64>
fn checked_hamming_distance(self, other: i32) -> Option<u64>
Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.
If the two numbers have opposite signs, then the number of flips would be infinite,
so the result is None
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl CheckedHammingDistance<i64> for i64
impl CheckedHammingDistance<i64> for i64
sourcefn checked_hamming_distance(self, other: i64) -> Option<u64>
fn checked_hamming_distance(self, other: i64) -> Option<u64>
Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.
If the two numbers have opposite signs, then the number of flips would be infinite,
so the result is None
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl CheckedHammingDistance<i128> for i128
impl CheckedHammingDistance<i128> for i128
sourcefn checked_hamming_distance(self, other: i128) -> Option<u64>
fn checked_hamming_distance(self, other: i128) -> Option<u64>
Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.
If the two numbers have opposite signs, then the number of flips would be infinite,
so the result is None
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl CheckedHammingDistance<isize> for isize
impl CheckedHammingDistance<isize> for isize
sourcefn checked_hamming_distance(self, other: isize) -> Option<u64>
fn checked_hamming_distance(self, other: isize) -> Option<u64>
Returns the Hamming distance between two numbers, or the number of bit flips needed to turn one into the other.
If the two numbers have opposite signs, then the number of flips would be infinite,
so the result is None
.
Worst-case complexity
Constant time and additional memory.
Examples
See here.