docs

You are reading the docs for v0.1.2. Nabi 0.1.2 is no longer supported. Latest release: v0.1.3 →

core::num::FloatingPoint

On this page

FloatingPointSource

pub trait FloatingPoint: Num + Neg<Output = Self>

The binary floating-point types f32 and f64 (not the unbounded float): their constants and math as one bound, T: FloatingPoint. Each method is the type's own of the same name. Swift's name; Rust's num::Float.

  • const NAN: Self§

    Source

    Not a number.

  • const INFINITY: Self§

    Source

    Positive infinity.

  • const NEG_INFINITY: Self§

    Source

    Negative infinity.

  • const EPSILON: Self§

    Source

    The gap between 1 and the next larger value.

  • const PI: Self§

    Source

    Pi.

  • const E: Self§

    Source

    Euler's number e.

  • fn abs(self) -> Self§

    Source

    The absolute value.

  • fn sqrt(self) -> Self§

    Source

    The square root; NaN for a negative value.

  • fn cbrt(self) -> Self§

    Source

    The cube root.

  • fn exp(self) -> Self§

    Source

    e^self.

  • fn ln(self) -> Self§

    Source

    The natural logarithm.

  • fn log2(self) -> Self§

    Source

    The base-2 logarithm.

  • fn log10(self) -> Self§

    Source

    The base-10 logarithm.

  • fn powi(self, n: i32) -> Self§

    Source

    self^n.

  • fn pow(self, exp: Self) -> Self§

    Source

    self^exp.

  • fn sin(self) -> Self§

    Source

    The sine (radians).

  • fn cos(self) -> Self§

    Source

    The cosine (radians).

  • fn tan(self) -> Self§

    Source

    The tangent (radians).

  • fn asin(self) -> Self§

    Source

    The arcsine.

  • fn acos(self) -> Self§

    Source

    The arccosine.

  • fn atan(self) -> Self§

    Source

    The arctangent.

  • fn atan2(self, other: Self) -> Self§

    Source

    The angle of the point (other, self).

  • fn sinh(self) -> Self§

    Source

    The hyperbolic sine.

  • fn cosh(self) -> Self§

    Source

    The hyperbolic cosine.

  • fn tanh(self) -> Self§

    Source

    The hyperbolic tangent.

  • fn hypot(self, other: Self) -> Self§

    Source

    sqrt(self^2 + other^2) without overflow on the way.

  • fn floor(self) -> Self§

    Source

    Rounded down.

  • fn ceil(self) -> Self§

    Source

    Rounded up.

  • fn round(self) -> Self§

    Source

    Rounded to the nearest, half away from zero.

  • fn trunc(self) -> Self§

    Source

    Rounded toward zero.

  • fn signum(self) -> Self§

    Source

    1 / -1 by the sign; NaN for NaN.

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

    Source

    self * a + b with one rounding.

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

    Source

    The smaller of the two; a NaN loses to a number.

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

    Source

    The larger of the two; a NaN loses to a number.

  • fn is_nan(self) -> bool§

    Source

    true for NaN.

  • fn is_infinite(self) -> bool§

    Source

    true for either infinity.

  • fn is_finite(self) -> bool§

    Source

    true for neither NaN nor an infinity.

  • fn total_cmp(self, other: Self) -> core::cmp::Ordering§

    Source

    The IEEE 754 total order (-NaN < -inf < .. < -0 < +0 < .. < inf < NaN).

  • fn to_f64(self) -> f64§

    Source

    self widened or kept as an f64.

  • fn from_f64(x: f64) -> Self§

    Source

    x rounded to Self (to nearest).

  • fn from_usize(n: usize) -> Self§

    Source

    n as Self, rounded to nearest past 2^24 (f32) / 2^53 (f64).