pub trait ExcessToSignedwhere
    Self: CastSigned,{
    // Required method
    fn excess_to_signed(&self, excess: &Self) -> Self::Target;

    // Provided method
    fn half_exc_to_signed(&self) -> Self::Target
       where Self: HalfExcess { ... }
}
Expand description

Trait for converting unsigned numbers into signed 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: i = u - N (i.e. N becomes the new zero).

Required Methods§

source

fn excess_to_signed(&self, excess: &Self) -> Self::Target

Performs a conversion from an “excess of N” number to a 2’s complement number. The input is actually unsigned.

Provided Methods§

source

fn half_exc_to_signed(&self) -> Self::Targetwhere Self: HalfExcess,

Performs a conversion from an “excess of N” number to a 2’s complement number, where N is half the maximum value of the unsigned input number.

Implementors§