Trait num_traits::sign::Signed [−][src]
pub trait Signed: Sized + Num + Neg<Output = Self> { fn abs(&self) -> Self; fn abs_sub(&self, other: &Self) -> Self; fn signum(&self) -> Self; fn is_positive(&self) -> bool; fn is_negative(&self) -> bool; }
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<T: Signed> Signed for Wrapping<T> where
Wrapping<T>: Num + Neg<Output = Wrapping<T>>, [src]
impl<T: Signed> Signed for Wrapping<T> where
Wrapping<T>: Num + Neg<Output = Wrapping<T>>, fn abs(&self) -> Self[src]
fn abs(&self) -> Selffn abs_sub(&self, other: &Self) -> Self[src]
fn abs_sub(&self, other: &Self) -> Selffn signum(&self) -> Self[src]
fn signum(&self) -> Selffn is_positive(&self) -> bool[src]
fn is_positive(&self) -> boolfn is_negative(&self) -> bool[src]
fn is_negative(&self) -> boolImplementors
impl Signed for isizeimpl Signed for i8impl Signed for i16impl Signed for i32impl Signed for i64impl Signed for i128impl Signed for f32impl Signed for f64