[−][src]Trait fixed::traits::FixedSigned
This trait provides common methods to all signed fixed-point numbers.
Required methods
fn abs(self) -> Self
Returns the absolute value.
fn signum(self) -> Self
Returns a number representing the sign of self
.
Panics
When debug assertions are enabled, this method panics
- if the value is positive and the fixed-point number has zero or one integer bits such that it cannot hold the value 1.
- if the value is negative and the fixed-point number has zero integer bits, such that it cannot hold the value −1.
When debug assertions are not enabled, the wrapped value can be returned in those cases, but it is not considered a breaking change if in the future it panics; using this method when 1 and −1 cannot be represented is almost certainly a bug.
fn checked_abs(self) -> Option<Self>
Checked absolute value. Returns the absolute value, or None
on overflow.
Overflow can only occur when trying to find the absolute value of the minimum value.
fn saturating_abs(self) -> Self
Saturating absolute value. Returns the absolute value, saturating on overflow.
Overflow can only occur when trying to find the absolute value of the minimum value.
fn wrapping_abs(self) -> Self
Wrapping absolute value. Returns the absolute value, wrapping on overflow.
Overflow can only occur when trying to find the absolute value of the minimum value.
fn overflowing_abs(self) -> (Self, bool)
Overflowing absolute value.
Returns a tuple of the fixed-point number and a bool
,
indicating whether an overflow has occurred. On overflow, the
wrapped value is returned.
fn is_positive(self) -> bool
Returns true
if the number is > 0.
fn is_negative(self) -> bool
Returns true
if the number is < 0.
Implementors
impl<Frac> FixedSigned for FixedI128<Frac> where
Frac: Unsigned + IsLessOrEqual<U128, Output = True>,
[src]
Frac: Unsigned + IsLessOrEqual<U128, Output = True>,
fn abs(self) -> Self
[src]
fn signum(self) -> Self
[src]
fn checked_abs(self) -> Option<Self>
[src]
fn saturating_abs(self) -> Self
[src]
fn wrapping_abs(self) -> Self
[src]
fn overflowing_abs(self) -> (Self, bool)
[src]
fn is_positive(self) -> bool
[src]
fn is_negative(self) -> bool
[src]
impl<Frac> FixedSigned for FixedI16<Frac> where
Frac: Unsigned + IsLessOrEqual<U16, Output = True>,
[src]
Frac: Unsigned + IsLessOrEqual<U16, Output = True>,
fn abs(self) -> Self
[src]
fn signum(self) -> Self
[src]
fn checked_abs(self) -> Option<Self>
[src]
fn saturating_abs(self) -> Self
[src]
fn wrapping_abs(self) -> Self
[src]
fn overflowing_abs(self) -> (Self, bool)
[src]
fn is_positive(self) -> bool
[src]
fn is_negative(self) -> bool
[src]
impl<Frac> FixedSigned for FixedI32<Frac> where
Frac: Unsigned + IsLessOrEqual<U32, Output = True>,
[src]
Frac: Unsigned + IsLessOrEqual<U32, Output = True>,
fn abs(self) -> Self
[src]
fn signum(self) -> Self
[src]
fn checked_abs(self) -> Option<Self>
[src]
fn saturating_abs(self) -> Self
[src]
fn wrapping_abs(self) -> Self
[src]
fn overflowing_abs(self) -> (Self, bool)
[src]
fn is_positive(self) -> bool
[src]
fn is_negative(self) -> bool
[src]
impl<Frac> FixedSigned for FixedI64<Frac> where
Frac: Unsigned + IsLessOrEqual<U64, Output = True>,
[src]
Frac: Unsigned + IsLessOrEqual<U64, Output = True>,
fn abs(self) -> Self
[src]
fn signum(self) -> Self
[src]
fn checked_abs(self) -> Option<Self>
[src]
fn saturating_abs(self) -> Self
[src]
fn wrapping_abs(self) -> Self
[src]
fn overflowing_abs(self) -> (Self, bool)
[src]
fn is_positive(self) -> bool
[src]
fn is_negative(self) -> bool
[src]
impl<Frac> FixedSigned for FixedI8<Frac> where
Frac: Unsigned + IsLessOrEqual<U8, Output = True>,
[src]
Frac: Unsigned + IsLessOrEqual<U8, Output = True>,