[−][src]Trait num_traits::sign::Signed
Useful functions for signed numbers (i.e. numbers that can be negative).
Required Methods
fn abs(&self) -> Self
Computes the absolute value.
For f32 and f64, NaN will be returned if the number is NaN.
For signed integers, ::MIN will be returned if the number is ::MIN.
fn abs_sub(&self, other: &Self) -> Self
The positive difference of two numbers.
Returns zero if the number is less than or equal to other, otherwise the difference
between self and other is returned.
fn signum(&self) -> Self
Returns the sign of the number.
For f32 and f64:
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) -> bool
Returns true if the number is positive and false if the number is zero or negative.
fn is_negative(&self) -> bool
Returns true if the number is negative and false if the number is zero or positive.
Implementations on Foreign Types
impl Signed for isize[src]
impl Signed for isizefn abs(&self) -> isize[src]
fn abs(&self) -> isizefn abs_sub(&self, other: &isize) -> isize[src]
fn abs_sub(&self, other: &isize) -> isizefn signum(&self) -> isize[src]
fn signum(&self) -> isizefn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolfn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolimpl Signed for i64[src]
impl Signed for i64fn abs(&self) -> i64[src]
fn abs(&self) -> i64fn abs_sub(&self, other: &i64) -> i64[src]
fn abs_sub(&self, other: &i64) -> i64fn signum(&self) -> i64[src]
fn signum(&self) -> i64fn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolfn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolimpl Signed for i8[src]
impl Signed for i8fn abs(&self) -> i8[src]
fn abs(&self) -> i8fn abs_sub(&self, other: &i8) -> i8[src]
fn abs_sub(&self, other: &i8) -> i8fn signum(&self) -> i8[src]
fn signum(&self) -> i8fn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolfn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolimpl<T> Signed for Wrapping<T> where
T: Signed,
Wrapping<T>: Num,
Wrapping<T>: Neg,
<Wrapping<T> as Neg>::Output == Wrapping<T>, [src]
impl<T> Signed for Wrapping<T> where
T: Signed,
Wrapping<T>: Num,
Wrapping<T>: Neg,
<Wrapping<T> as Neg>::Output == Wrapping<T>, fn abs(&self) -> Wrapping<T>[src]
fn abs(&self) -> Wrapping<T>fn abs_sub(&self, other: &Wrapping<T>) -> Wrapping<T>[src]
fn abs_sub(&self, other: &Wrapping<T>) -> Wrapping<T>fn signum(&self) -> Wrapping<T>[src]
fn signum(&self) -> Wrapping<T>fn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolfn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolimpl Signed for i32[src]
impl Signed for i32fn abs(&self) -> i32[src]
fn abs(&self) -> i32fn abs_sub(&self, other: &i32) -> i32[src]
fn abs_sub(&self, other: &i32) -> i32fn signum(&self) -> i32[src]
fn signum(&self) -> i32fn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolfn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolimpl Signed for f64[src]
impl Signed for f64fn abs(&self) -> f64[src]
fn abs(&self) -> f64Computes the absolute value. Returns NAN if the number is NAN.
fn abs_sub(&self, other: &f64) -> f64[src]
fn abs_sub(&self, other: &f64) -> f64The positive difference of two numbers. Returns 0.0 if the number is
less than or equal to other, otherwise the difference betweenself
and other is returned.
fn signum(&self) -> f64[src]
fn signum(&self) -> f64Returns
1.0if the number is positive,+0.0orINFINITY-1.0if the number is negative,-0.0orNEG_INFINITYNANif the number is NaN
fn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolReturns true if the number is positive, including +0.0 and INFINITY
fn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolReturns true if the number is negative, including -0.0 and NEG_INFINITY
impl Signed for f32[src]
impl Signed for f32fn abs(&self) -> f32[src]
fn abs(&self) -> f32Computes the absolute value. Returns NAN if the number is NAN.
fn abs_sub(&self, other: &f32) -> f32[src]
fn abs_sub(&self, other: &f32) -> f32The positive difference of two numbers. Returns 0.0 if the number is
less than or equal to other, otherwise the difference betweenself
and other is returned.
fn signum(&self) -> f32[src]
fn signum(&self) -> f32Returns
1.0if the number is positive,+0.0orINFINITY-1.0if the number is negative,-0.0orNEG_INFINITYNANif the number is NaN
fn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolReturns true if the number is positive, including +0.0 and INFINITY
fn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolReturns true if the number is negative, including -0.0 and NEG_INFINITY
impl Signed for i16[src]
impl Signed for i16fn abs(&self) -> i16[src]
fn abs(&self) -> i16fn abs_sub(&self, other: &i16) -> i16[src]
fn abs_sub(&self, other: &i16) -> i16fn signum(&self) -> i16[src]
fn signum(&self) -> i16fn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolfn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolimpl Signed for i128[src]
impl Signed for i128fn abs(&self) -> i128[src]
fn abs(&self) -> i128fn abs_sub(&self, other: &i128) -> i128[src]
fn abs_sub(&self, other: &i128) -> i128fn signum(&self) -> i128[src]
fn signum(&self) -> i128fn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolfn is_negative(&self) -> bool[src]
fn is_negative(&self) -> bool