Trait gardiz::bits::SignedToExcess
source · pub trait SignedToExcesswhere
Self: CastUnsigned,{
// Required method
fn signed_to_excess(&self, excess: &Self::Target) -> Self::Target;
// Provided method
fn signed_to_half_exc(&self) -> Self::Target
where Self::Target: HalfExcess { ... }
}
Expand description
Trait for converting signed numbers into unsigned numbers, but instead of a
true bit-cast, this conversion should treat the unsigned number as “excess
of N” number. So, conversion should be equivalent to this: u = i + N
(i.e.
N
becomes the new zero).
Required Methods§
sourcefn signed_to_excess(&self, excess: &Self::Target) -> Self::Target
fn signed_to_excess(&self, excess: &Self::Target) -> Self::Target
Performs a conversion from a 2’s complement number into an “excess of N” number. The input is actually signed.
Provided Methods§
sourcefn signed_to_half_exc(&self) -> Self::Targetwhere
Self::Target: HalfExcess,
fn signed_to_half_exc(&self) -> Self::Targetwhere Self::Target: HalfExcess,
Performs a conversion from a 2’s complement number into an “excess of N”
number, where N
is half the maximum value of the unsigned input
number.