Expand description
A collection of traits related to manipulating integer bits or similar operations, such as (absolute) distance.
Traits
- Trait for bit-casts from unsigned integers to 2’s complement signed integers.
 - Trait for bit-casts from 2’s complement signed integers to unsigned integers.
 - 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.Nbecomes the new zero). - Trait for getting the “excess” that is the half of an unsigned type’s maximum value, typically
1000...0000. Types should not worry with this trait, but instead implementUnsignedandBounded, since there is a blank implementation for them, and there is no other way to implement the trait (UnsignedandBoundedare super traits of this trait). - 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.Nbecomes the new zero).