[src]

Trait std::num::Signed

pub trait Signed: Num + Neg<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 float, f32, and f64, NaN will be returned if the number is NaN.

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 float, f32, f64: * 1.0 if the number is positive, +0.0 or INFINITY * -1.0 if the number is negative, -0.0 or NEG_INFINITY * NaN if the number is NaN

For int: * 0 if the number is zero * 1 if the number is positive * -1 if 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.

Implementors