Trait sp_arithmetic::traits::Signed [−][src]
Useful functions for signed numbers (i.e. numbers that can be negative).
Required methods
pub fn abs(&self) -> Self
[src]
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
.
pub fn abs_sub(&self, other: &Self) -> Self
[src]
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.
pub fn signum(&self) -> Self
[src]
Returns the sign of the number.
For f32
and f64
:
1.0
if the number is positive,+0.0
orINFINITY
-1.0
if the number is negative,-0.0
orNEG_INFINITY
NaN
if the number isNaN
For signed integers:
0
if the number is zero1
if the number is positive-1
if the number is negative
pub fn is_positive(&self) -> bool
[src]
Returns true if the number is positive and false if the number is zero or negative.
pub fn is_negative(&self) -> bool
[src]
Returns true if the number is negative and false if the number is zero or positive.
Implementations on Foreign Types
impl Signed for i16
[src]
pub fn abs(&self) -> i16
[src]
pub fn abs_sub(&self, other: &i16) -> i16
[src]
pub fn signum(&self) -> i16
[src]
pub fn is_positive(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
[src]
impl<T> Signed for Wrapping<T> where
T: Signed,
Wrapping<T>: Num,
Wrapping<T>: Neg,
<Wrapping<T> as Neg>::Output == Wrapping<T>,
[src]
T: Signed,
Wrapping<T>: Num,
Wrapping<T>: Neg,
<Wrapping<T> as Neg>::Output == Wrapping<T>,
pub fn abs(&self) -> Wrapping<T>
[src]
pub fn abs_sub(&self, other: &Wrapping<T>) -> Wrapping<T>
[src]
pub fn signum(&self) -> Wrapping<T>
[src]
pub fn is_positive(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
[src]
impl Signed for isize
[src]
pub fn abs(&self) -> isize
[src]
pub fn abs_sub(&self, other: &isize) -> isize
[src]
pub fn signum(&self) -> isize
[src]
pub fn is_positive(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
[src]
impl Signed for i32
[src]
pub fn abs(&self) -> i32
[src]
pub fn abs_sub(&self, other: &i32) -> i32
[src]
pub fn signum(&self) -> i32
[src]
pub fn is_positive(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
[src]
impl Signed for f64
[src]
pub fn abs(&self) -> f64
[src]
Computes the absolute value. Returns NAN
if the number is NAN
.
pub fn abs_sub(&self, other: &f64) -> f64
[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.
pub fn signum(&self) -> f64
[src]
Returns
1.0
if the number is positive,+0.0
orINFINITY
-1.0
if the number is negative,-0.0
orNEG_INFINITY
NAN
if the number is NaN
pub fn is_positive(&self) -> bool
[src]
Returns true
if the number is positive, including +0.0
and INFINITY
pub fn is_negative(&self) -> bool
[src]
Returns true
if the number is negative, including -0.0
and NEG_INFINITY
impl Signed for i128
[src]
pub fn abs(&self) -> i128
[src]
pub fn abs_sub(&self, other: &i128) -> i128
[src]
pub fn signum(&self) -> i128
[src]
pub fn is_positive(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
[src]
impl Signed for i8
[src]
pub fn abs(&self) -> i8
[src]
pub fn abs_sub(&self, other: &i8) -> i8
[src]
pub fn signum(&self) -> i8
[src]
pub fn is_positive(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
[src]
impl Signed for f32
[src]
pub fn abs(&self) -> f32
[src]
Computes the absolute value. Returns NAN
if the number is NAN
.
pub fn abs_sub(&self, other: &f32) -> f32
[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.
pub fn signum(&self) -> f32
[src]
Returns
1.0
if the number is positive,+0.0
orINFINITY
-1.0
if the number is negative,-0.0
orNEG_INFINITY
NAN
if the number is NaN
pub fn is_positive(&self) -> bool
[src]
Returns true
if the number is positive, including +0.0
and INFINITY
pub fn is_negative(&self) -> bool
[src]
Returns true
if the number is negative, including -0.0
and NEG_INFINITY