Trait Signed
trait Signed: Sized + Num + Neg<Output = Self>
Useful functions for signed numbers (i.e. numbers that can be negative).
Required Methods
fn abs(self: &Self) -> SelfComputes the absolute value.
For
f32andf64,NaNwill be returned if the number isNaN.For signed integers,
::MINwill be returned if the number is::MIN.fn abs_sub(self: &Self, other: &Self) -> SelfThe positive difference of two numbers.
Returns
zeroif the number is less than or equal toother, otherwise the difference betweenselfandotheris returned.fn signum(self: &Self) -> SelfReturns the sign of the number.
For
f32andf64:1.0if the number is positive,+0.0orINFINITY-1.0if the number is negative,-0.0orNEG_INFINITYNaNif the number isNaN
For signed integers:
0if the number is zero1if the number is positive-1if the number is negative
fn is_positive(self: &Self) -> boolReturns true if the number is positive and false if the number is zero or negative.
fn is_negative(self: &Self) -> boolReturns true if the number is negative and false if the number is zero or positive.
Implementors
impl Signed for f32impl Signed for i64impl Signed for i8impl<T: Signed> Signed for Wrapping<T>impl Signed for i32impl Signed for isizeimpl Signed for f64impl Signed for i128impl Signed for i16