[src]

Trait std::num::Float

pub trait Float: Signed + Round + Primitive {
    fn max(self, other: Self) -> Self;
    fn min(self, other: Self) -> Self;
    fn nan() -> Self;
    fn infinity() -> Self;
    fn neg_infinity() -> Self;
    fn neg_zero() -> 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 ldexp(x: Self, exp: int) -> Self;
    fn frexp(&self) -> (Self, int);
    fn exp_m1(&self) -> Self;
    fn ln_1p(&self) -> Self;
    fn mul_add(&self, a: Self, b: Self) -> Self;
    fn next_after(&self, other: Self) -> Self;
    fn integer_decode(&self) -> (u64, i16, i8);
    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 sqrt2() -> Self;
    fn frac_1_sqrt2() -> Self;
    fn e() -> Self;
    fn log2_e() -> Self;
    fn log10_e() -> Self;
    fn ln_2() -> Self;
    fn ln_10() -> Self;
    fn recip(&self) -> Self;
    fn powf(&self, n: &Self) -> Self;
    fn sqrt(&self) -> Self;
    fn rsqrt(&self) -> Self;
    fn cbrt(&self) -> Self;
    fn hypot(&self, other: &Self) -> Self;
    fn sin(&self) -> Self;
    fn cos(&self) -> Self;
    fn tan(&self) -> Self;
    fn asin(&self) -> Self;
    fn acos(&self) -> Self;
    fn atan(&self) -> Self;
    fn atan2(&self, other: &Self) -> Self;
    fn sin_cos(&self) -> (Self, 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 sinh(&self) -> Self;
    fn cosh(&self) -> Self;
    fn tanh(&self) -> Self;
    fn asinh(&self) -> Self;
    fn acosh(&self) -> Self;
    fn atanh(&self) -> Self;
    fn to_degrees(&self) -> Self;
    fn to_radians(&self) -> Self;
}

Operations on primitive floating point numbers.

Required Methods

fn max(self, other: Self) -> Self

Returns the maximum of the two numbers.

fn min(self, other: Self) -> Self

Returns the minimum of the two numbers.

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 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 binary digits of exponent that this type supports.

fn epsilon() -> Self

Returns the smallest positive number that this type can represent.

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 ldexp(x: Self, exp: int) -> Self

Constructs a floating point number created by multiplying x by 2 raised to the power of exp.

fn frexp(&self) -> (Self, int)

Breaks the number into a normalized fraction and a base-2 exponent, satisfying:

  • self = x * pow(2, exp)

  • 0.5 <= abs(x) < 1.0

fn exp_m1(&self) -> Self

Returns the exponential of the number, minus 1, in a way that is accurate even if the number is close to zero.

fn ln_1p(&self) -> Self

Returns the natural logarithm of the number plus 1 (ln(1+n)) more accurately than if the operations were performed separately.

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 next_after(&self, other: Self) -> Self

Returns the next representable floating-point value in the direction of other.

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

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

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 sqrt2() -> Self

sqrt(2.0).

fn frac_1_sqrt2() -> Self

1.0 / sqrt(2.0).

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 recip(&self) -> Self

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

fn powf(&self, n: &Self) -> Self

Raise a number to a power.

fn sqrt(&self) -> Self

Take the square root of a number.

fn rsqrt(&self) -> Self

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

fn cbrt(&self) -> Self

Take the cubic root of a number.

fn hypot(&self, other: &Self) -> Self

Calculate the length of the hypotenuse of a right-angle triangle given legs of length x and y.

fn sin(&self) -> Self

Computes the sine of a number (in radians).

fn cos(&self) -> Self

Computes the cosine of a number (in radians).

fn tan(&self) -> Self

Computes the tangent of a number (in radians).

fn asin(&self) -> Self

Computes the arcsine of a number. Return value is in radians in the range [-pi/2, pi/2] or NaN if the number is outside the range [-1, 1].

fn acos(&self) -> Self

Computes the arccosine of a number. Return value is in radians in the range [0, pi] or NaN if the number is outside the range [-1, 1].

fn atan(&self) -> Self

Computes the arctangent of a number. Return value is in radians in the range [-pi/2, pi/2];

fn atan2(&self, other: &Self) -> Self

Computes the four quadrant arctangent of a number, y, and another number x. Return value is in radians in the range [-pi, pi].

fn sin_cos(&self) -> (Self, Self)

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).

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 sinh(&self) -> Self

Hyperbolic sine function.

fn cosh(&self) -> Self

Hyperbolic cosine function.

fn tanh(&self) -> Self

Hyperbolic tangent function.

fn asinh(&self) -> Self

Inverse hyperbolic sine function.

fn acosh(&self) -> Self

Inverse hyperbolic cosine function.

fn atanh(&self) -> Self

Inverse hyperbolic tangent function.

fn to_degrees(&self) -> Self

Convert radians to degrees.

fn to_radians(&self) -> Self

Convert degrees to radians.

Implementors