Trait core::num::Float
[−]
[src]
pub trait Float: Sized { fn nan() -> Self; fn infinity() -> Self; fn neg_infinity() -> Self; fn neg_zero() -> Self; fn zero() -> Self; fn one() -> Self; fn is_nan(self) -> bool; fn is_infinite(self) -> bool; fn is_finite(self) -> bool; fn is_normal(self) -> bool; fn classify(self) -> FpCategory; fn integer_decode(self) -> (u64, i16, i8); fn abs(self) -> Self; fn signum(self) -> Self; fn is_sign_positive(self) -> bool; fn is_sign_negative(self) -> bool; fn recip(self) -> Self; fn powi(self, n: i32) -> Self; fn to_degrees(self) -> Self; fn to_radians(self) -> Self; }
A built-in floating point number.
Required Methods
fn nan() -> Self
Returns the NaN value.
fn infinity() -> Self
Returns the infinite value.
fn neg_infinity() -> Self
Returns the negative infinite value.
fn neg_zero() -> Self
Returns -0.0.
fn zero() -> Self
Returns 0.0.
fn one() -> Self
Returns 1.0.
fn is_nan(self) -> bool
Returns true if this value is NaN and false otherwise.
fn is_infinite(self) -> bool
Returns true if this value is positive infinity or negative infinity and false otherwise.
fn is_finite(self) -> bool
Returns true if this number is neither infinite nor NaN.
fn is_normal(self) -> bool
Returns true if this number is neither zero, infinite, denormal, or NaN.
fn classify(self) -> FpCategory
Returns the category that this number falls into.
fn integer_decode(self) -> (u64, i16, i8)
Returns the mantissa, exponent and sign as integers, respectively.
fn abs(self) -> Self
Computes the absolute value of self
. Returns Float::nan()
if the
number is Float::nan()
.
fn signum(self) -> Self
Returns a number that represents the sign of self
.
1.0
if the number is positive,+0.0
orFloat::infinity()
-1.0
if the number is negative,-0.0
orFloat::neg_infinity()
Float::nan()
if the number isFloat::nan()
fn is_sign_positive(self) -> bool
Returns true
if self
is positive, including +0.0
and
Float::infinity()
.
fn is_sign_negative(self) -> bool
Returns true
if self
is negative, including -0.0
and
Float::neg_infinity()
.
fn recip(self) -> Self
Take the reciprocal (inverse) of a number, 1/x
.
fn powi(self, n: i32) -> Self
Raise a number to an integer power.
Using this function is generally faster than using powf
fn to_degrees(self) -> Self
Convert radians to degrees.
fn to_radians(self) -> Self
Convert degrees to radians.