Trait num_traits::sign::Signed [] [src]

pub trait Signed: 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

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.

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.

Returns the sign of the number.

For f32 and 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 signed integers:

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative

Returns true if the number is positive and false if the number is zero or negative.

Returns true if the number is negative and false if the number is zero or positive.

Implementations on Foreign Types

impl Signed for i8
[src]

[src]

[src]

[src]

[src]

[src]

impl Signed for i64
[src]

[src]

[src]

[src]

[src]

[src]

impl Signed for i16
[src]

[src]

[src]

[src]

[src]

[src]

impl Signed for f64
[src]

[src]

Computes the absolute value. Returns NAN if the number is NAN.

[src]

The 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.

[src]

Returns

  • 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

[src]

Returns true if the number is positive, including +0.0 and INFINITY

[src]

Returns true if the number is negative, including -0.0 and NEG_INFINITY

impl<T> Signed for Wrapping<T> where
    T: Signed,
    Wrapping<T>: Num,
    Wrapping<T>: Neg,
    <Wrapping<T> as Neg>::Output == Wrapping<T>, 
[src]

[src]

[src]

[src]

[src]

[src]

impl Signed for f32
[src]

[src]

Computes the absolute value. Returns NAN if the number is NAN.

[src]

The 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.

[src]

Returns

  • 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

[src]

Returns true if the number is positive, including +0.0 and INFINITY

[src]

Returns true if the number is negative, including -0.0 and NEG_INFINITY

impl Signed for isize
[src]

[src]

[src]

[src]

[src]

[src]

impl Signed for i32
[src]

[src]

[src]

[src]

[src]

[src]

Implementors