Trait std::num::FloatUnstable [-]  [+] [src]

pub trait Float: NumCast + Add<Self, Self> + Sub<Self, Self> + Mul<Self, Self> + Div<Self, Self> + Rem<Self, Self> + Neg<Self> + PartialEq<Self> + PartialOrd<Self> + Clone {
    fn nan() -> Self;
    fn infinity() -> Self;
    fn neg_infinity() -> Self;
    fn zero() -> Self;
    fn neg_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 mantissa_digits(unused_self: Option<Self>) -> uint;
    fn digits(unused_self: Option<Self>) -> uint;
    fn epsilon() -> Self;
    fn min_exp(unused_self: Option<Self>) -> int;
    fn max_exp(unused_self: Option<Self>) -> int;
    fn min_10_exp(unused_self: Option<Self>) -> int;
    fn max_10_exp(unused_self: Option<Self>) -> int;
    fn min_value() -> Self;
    fn min_pos_value(unused_self: Option<Self>) -> Self;
    fn max_value() -> Self;
    fn integer_decode(self) -> (u64, i16, i8);
    fn floor(self) -> Self;
    fn ceil(self) -> Self;
    fn round(self) -> Self;
    fn trunc(self) -> Self;
    fn fract(self) -> Self;
    fn abs(self) -> Self;
    fn signum(self) -> Self;
    fn is_positive(self) -> bool;
    fn is_negative(self) -> bool;
    fn mul_add(self, a: Self, b: Self) -> Self;
    fn recip(self) -> Self;
    fn powi(self, n: i32) -> Self;
    fn powf(self, n: Self) -> Self;
    fn sqrt2() -> Self;
    fn frac_1_sqrt2() -> Self;
    fn sqrt(self) -> Self;
    fn rsqrt(self) -> Self;
    fn pi() -> Self;
    fn two_pi() -> Self;
    fn frac_pi_2() -> Self;
    fn frac_pi_3() -> Self;
    fn frac_pi_4() -> Self;
    fn frac_pi_6() -> Self;
    fn frac_pi_8() -> Self;
    fn frac_1_pi() -> Self;
    fn frac_2_pi() -> Self;
    fn frac_2_sqrtpi() -> Self;
    fn e() -> Self;
    fn log2_e() -> Self;
    fn log10_e() -> Self;
    fn ln_2() -> Self;
    fn ln_10() -> Self;
    fn exp(self) -> Self;
    fn exp2(self) -> Self;
    fn ln(self) -> Self;
    fn log(self, base: Self) -> Self;
    fn log2(self) -> Self;
    fn log10(self) -> 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 zero() -> Self

Returns the 0 value.

fn neg_zero() -> Self

Returns -0.0.

fn one() -> Self

Returns the 1 value.

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 mantissa_digits(unused_self: Option<Self>) -> uint

Returns the number of binary digits of mantissa that this type supports.

fn digits(unused_self: Option<Self>) -> uint

Returns the number of base-10 digits of precision that this type supports.

fn epsilon() -> Self

Returns the difference between 1.0 and the smallest representable number larger than 1.0.

fn min_exp(unused_self: Option<Self>) -> int

Returns the minimum binary exponent that this type can represent.

fn max_exp(unused_self: Option<Self>) -> int

Returns the maximum binary exponent that this type can represent.

fn min_10_exp(unused_self: Option<Self>) -> int

Returns the minimum base-10 exponent that this type can represent.

fn max_10_exp(unused_self: Option<Self>) -> int

Returns the maximum base-10 exponent that this type can represent.

fn min_value() -> Self

Returns the smallest finite value that this type can represent.

fn min_pos_value(unused_self: Option<Self>) -> Self

Returns the smallest normalized positive number that this type can represent.

fn max_value() -> Self

Returns the largest finite value that this type can represent.

fn integer_decode(self) -> (u64, i16, i8)

Returns the mantissa, exponent and sign as integers, respectively.

fn floor(self) -> Self

Return the largest integer less than or equal to a number.

fn ceil(self) -> Self

Return the smallest integer greater than or equal to a number.

fn round(self) -> Self

Return the nearest integer to a number. Round half-way cases away from 0.0.

fn trunc(self) -> Self

Return the integer part of a number.

fn fract(self) -> Self

Return the fractional part of a number.

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_positive(self) -> bool

Returns true if self is positive, including +0.0 and Float::infinity().

fn is_negative(self) -> bool

Returns true if self is negative, including -0.0 and Float::neg_infinity().

fn mul_add(self, a: Self, b: Self) -> Self

Fused multiply-add. Computes (self * a) + b with only one rounding error. This produces a more accurate result with better performance than a separate multiplication operation followed by an add.

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 powf(self, n: Self) -> Self

Raise a number to a floating point power.

fn sqrt2() -> Self

sqrt(2.0).

fn frac_1_sqrt2() -> Self

1.0 / sqrt(2.0).

fn sqrt(self) -> Self

Take the square root of a number.

Returns NaN if self is a negative number.

fn rsqrt(self) -> Self

Take the reciprocal (inverse) square root of a number, 1/sqrt(x).

fn pi() -> Self

Archimedes' constant.

fn two_pi() -> Self

2.0 * pi.

fn frac_pi_2() -> Self

pi / 2.0.

fn frac_pi_3() -> Self

pi / 3.0.

fn frac_pi_4() -> Self

pi / 4.0.

fn frac_pi_6() -> Self

pi / 6.0.

fn frac_pi_8() -> Self

pi / 8.0.

fn frac_1_pi() -> Self

1.0 / pi.

fn frac_2_pi() -> Self

2.0 / pi.

fn frac_2_sqrtpi() -> Self

2.0 / sqrt(pi).

fn e() -> Self

Euler's number.

fn log2_e() -> Self

log2(e).

fn log10_e() -> Self

log10(e).

fn ln_2() -> Self

ln(2.0).

fn ln_10() -> Self

ln(10.0).

fn exp(self) -> Self

Returns e^(self), (the exponential function).

fn exp2(self) -> Self

Returns 2 raised to the power of the number, 2^(self).

fn ln(self) -> Self

Returns the natural logarithm of the number.

fn log(self, base: Self) -> Self

Returns the logarithm of the number with respect to an arbitrary base.

fn log2(self) -> Self

Returns the base 2 logarithm of the number.

fn log10(self) -> Self

Returns the base 10 logarithm of the number.

fn to_degrees(self) -> Self

Convert radians to degrees.

fn to_radians(self) -> Self

Convert degrees to radians.

Implementors