pub trait FixedUnsigned: Fixedwhere
Self: Div<<Self as Fixed>::NonZeroBits, Output = Self> + DivAssign<<Self as Fixed>::NonZeroBits>,{
Show 19 methods
// Required methods
fn significant_bits(self) -> u32;
fn is_power_of_two(self) -> bool;
fn highest_one(self) -> Self;
fn next_power_of_two(self) -> Self;
fn add_signed(self, rhs: Self::Signed) -> Self;
fn sub_signed(self, rhs: Self::Signed) -> Self;
fn checked_next_power_of_two(self) -> Option<Self>;
fn checked_add_signed(self, rhs: Self::Signed) -> Option<Self>;
fn checked_sub_signed(self, rhs: Self::Signed) -> Option<Self>;
fn saturating_add_signed(self, rhs: Self::Signed) -> Self;
fn saturating_sub_signed(self, rhs: Self::Signed) -> Self;
fn wrapping_next_power_of_two(self) -> Self;
fn wrapping_add_signed(self, rhs: Self::Signed) -> Self;
fn wrapping_sub_signed(self, rhs: Self::Signed) -> Self;
fn unwrapped_next_power_of_two(self) -> Self;
fn unwrapped_add_signed(self, rhs: Self::Signed) -> Self;
fn unwrapped_sub_signed(self, rhs: Self::Signed) -> Self;
fn overflowing_add_signed(self, rhs: Self::Signed) -> (Self, bool);
fn overflowing_sub_signed(self, rhs: Self::Signed) -> (Self, bool);
}Expand description
This trait provides methods common to all unsigned fixed-point numbers.
Methods common to all fixed-point numbers including signed
fixed-point numbers are provided by the Fixed supertrait.
This trait is sealed and cannot be implemented for more types; it
is implemented for FixedU8, FixedU16, FixedU32,
FixedU64, and FixedU128.
Required Methods§
Sourcefn significant_bits(self) -> u32
fn significant_bits(self) -> u32
Returns the number of bits required to represent the value.
See also
FixedU32::significant_bits.
Sourcefn is_power_of_two(self) -> bool
fn is_power_of_two(self) -> bool
Returns true if the fixed-point number is
2k for some integer k.
See also
FixedU32::is_power_of_two.
Sourcefn highest_one(self) -> Self
fn highest_one(self) -> Self
Returns the highest one in the binary representation, or zero
if self is zero.
See also FixedU32::highest_one.
Sourcefn next_power_of_two(self) -> Self
fn next_power_of_two(self) -> Self
Returns the smallest power of two that is ≥ self.
See also
FixedU32::next_power_of_two.
Sourcefn add_signed(self, rhs: Self::Signed) -> Self
fn add_signed(self, rhs: Self::Signed) -> Self
Addition with an signed fixed-point number.
See also FixedU32::add_signed.
Sourcefn sub_signed(self, rhs: Self::Signed) -> Self
fn sub_signed(self, rhs: Self::Signed) -> Self
Subtraction with an signed fixed-point number.
See also FixedU32::sub_signed.
Sourcefn checked_next_power_of_two(self) -> Option<Self>
fn checked_next_power_of_two(self) -> Option<Self>
Returns the smallest power of two that is ≥ self, or None if the
next power of two is too large to represent.
See also
FixedU32::checked_next_power_of_two.
Sourcefn checked_add_signed(self, rhs: Self::Signed) -> Option<Self>
fn checked_add_signed(self, rhs: Self::Signed) -> Option<Self>
Checked addition with an signed fixed-point number. Returns the sum,
or None on overflow.
See also
FixedU32::checked_add_signed.
Sourcefn checked_sub_signed(self, rhs: Self::Signed) -> Option<Self>
fn checked_sub_signed(self, rhs: Self::Signed) -> Option<Self>
Checked subtraction with an signed fixed-point number. Returns the
difference, or None on overflow.
See also FixedU32::checked_sub_signed.
Sourcefn saturating_add_signed(self, rhs: Self::Signed) -> Self
fn saturating_add_signed(self, rhs: Self::Signed) -> Self
Saturating addition with an signed fixed-point number. Returns the sum, saturating on overflow.
See also
FixedU32::saturating_add_signed.
Sourcefn saturating_sub_signed(self, rhs: Self::Signed) -> Self
fn saturating_sub_signed(self, rhs: Self::Signed) -> Self
Saturating subtraction with an signed fixed-point number. Returns the difference, saturating on overflow.
See also
FixedU32::saturating_sub_signed.
Sourcefn wrapping_next_power_of_two(self) -> Self
fn wrapping_next_power_of_two(self) -> Self
Returns the smallest power of two that is ≥ self, wrapping
to 0 if the next power of two is too large to represent.
See also
FixedU32::wrapping_next_power_of_two.
Sourcefn wrapping_add_signed(self, rhs: Self::Signed) -> Self
fn wrapping_add_signed(self, rhs: Self::Signed) -> Self
Wrapping addition with an signed fixed-point number. Returns the sum, wrapping on overflow.
See also
FixedU32::wrapping_add_signed.
Sourcefn wrapping_sub_signed(self, rhs: Self::Signed) -> Self
fn wrapping_sub_signed(self, rhs: Self::Signed) -> Self
Wrapping subtraction with an signed fixed-point number. Returns the difference, wrapping on overflow.
See also
FixedU32::wrapping_sub_signed.
Sourcefn unwrapped_next_power_of_two(self) -> Self
fn unwrapped_next_power_of_two(self) -> Self
Returns the smallest power of two that is ≥ self, panicking
if the next power of two is too large to represent.
See also
FixedU32::unwrapped_next_power_of_two.
§Panics
Panics if the result does not fit.
Sourcefn unwrapped_add_signed(self, rhs: Self::Signed) -> Self
fn unwrapped_add_signed(self, rhs: Self::Signed) -> Self
Unwrapped addition with an signed fixed-point number. Returns the sum, panicking on overflow.
See also
FixedU32::unwrapped_add_signed.
§Panics
Panics if the result does not fit.
Sourcefn unwrapped_sub_signed(self, rhs: Self::Signed) -> Self
fn unwrapped_sub_signed(self, rhs: Self::Signed) -> Self
Unwrapped subtraction with an signed fixed-point number. Returns the difference, panicking on overflow.
See also
FixedU32::unwrapped_sub_signed.
§Panics
Panics if the result does not fit.
Sourcefn overflowing_add_signed(self, rhs: Self::Signed) -> (Self, bool)
fn overflowing_add_signed(self, rhs: Self::Signed) -> (Self, bool)
Overflowing addition with an signed fixed-point number.
Returns a tuple of the sum and a bool, indicating whether an
overflow has occurred. On overflow, the wrapped value is returned.
See also
FixedU32::overflowing_add_signed.
Sourcefn overflowing_sub_signed(self, rhs: Self::Signed) -> (Self, bool)
fn overflowing_sub_signed(self, rhs: Self::Signed) -> (Self, bool)
Overflowing subtraction with an signed fixed-point number.
Returns a tuple of the difference and a bool, indicating whether
an overflow has occurred. On overflow, the wrapped value is returned.
See also
FixedU32::overflowing_sub_signed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.