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;
}
Unstable (core_float #27702)

: stable interface is via impl f{32,64} in later crates

A built-in floating point number.

Required Methods

fn nan() -> Self

Unstable (float_extras #27752)

: needs removal

Returns the NaN value.

fn infinity() -> Self

Unstable (float_extras #27752)

: needs removal

Returns the infinite value.

fn neg_infinity() -> Self

Unstable (float_extras #27752)

: needs removal

Returns the negative infinite value.

fn neg_zero() -> Self

Unstable (float_extras #27752)

: needs removal

Returns -0.0.

fn zero() -> Self

Unstable (float_extras #27752)

: needs removal

Returns 0.0.

fn one() -> Self

Unstable (float_extras #27752)

: needs removal

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)

Unstable (float_extras #27752)

: signature is undecided

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 or Float::infinity()
  • -1.0 if the number is negative, -0.0 or Float::neg_infinity()
  • Float::nan() if the number is Float::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

Unstable (float_extras #27752)

: desirability is unclear

Convert radians to degrees.

fn to_radians(self) -> Self

Unstable (float_extras #27752)

: desirability is unclear

Convert degrees to radians.

Implementors