rokdocs
v0.1

rok::core::num::floats

rok::core::num::floats - f32 / f64 inherent methods and constants (stdlib spec 2.1.4). The math functions are libm's (floor, sin, pow, ..) behind the runtime's rok_f64_* / rok_f32_* symbols (runtime/rokr/src/math.rs); to_bits / from_bits reinterpret through a union. sqrt is the Sqrt trait's (num.rok).

Implementations

impl f64

  • pub const EPSILON: f64 = 2.2204460492503131e-16
  • pub const MAX: f64 = 1.7976931348623157e308
  • pub const MIN: f64 = -1.7976931348623157e308
  • pub const MIN_POSITIVE: f64 = 2.2250738585072014e-308
  • pub const NAN: f64 = 0.0 / 0.0
  • pub const INFINITY: f64 = 1.0 / 0.0
  • pub const NEG_INFINITY: f64 = -1.0 / 0.0
  • pub const PI: f64 = 3.14159265358979323846264338327950288
  • pub const TAU: f64 = 6.28318530717958647692528676655900577
  • pub const E: f64 = 2.71828182845904523536028747135266250
  • pub const FRAC_PI_2: f64 = 1.57079632679489661923132169163975144
  • pub const FRAC_PI_4: f64 = 0.785398163397448309615660845819875721
  • pub const FRAC_1_PI: f64 = 0.318309886183790671537767526745028724
  • pub const SQRT_2: f64 = 1.41421356237309504880168872420969808
  • pub const FRAC_1_SQRT_2: f64 = 0.707106781186547524400844362104849039
  • pub const LN_2: f64 = 0.693147180559945309417232121458176568
  • pub const LN_10: f64 = 2.30258509299404568401799145468436421
  • pub const LOG2_E: f64 = 1.44269504088896340735992468100189214
  • pub const LOG10_E: f64 = 0.434294481903251827651128918916605082
  • pub const fn nan() -> f64
  • pub const fn infinity() -> f64
  • pub const fn neg_infinity() -> f64
  • pub const fn epsilon() -> f64

    The gap between 1.0 and the next f64 (EPSILON).

  • pub const fn to_bits(self) -> u64

    The IEEE 754 bit pattern.

  • pub const fn from_bits(bits: u64) -> f64
  • pub const fn is_nan(self) -> bool
  • pub const fn is_infinite(self) -> bool
  • pub const fn is_finite(self) -> bool
  • pub const fn is_normal(self) -> bool

    Neither zero, subnormal, infinite nor NaN.

  • pub const fn is_sign_positive(self) -> bool
  • pub const fn is_sign_negative(self) -> bool
  • pub const fn floor(self) -> f64

    Largest integer <= self.

  • pub const fn ceil(self) -> f64

    Smallest integer >= self.

  • pub const fn round(self) -> f64

    Nearest integer, halves away from zero.

  • pub const fn trunc(self) -> f64

    Integer part (toward zero).

  • pub const fn abs(self) -> f64
  • pub fn cbrt(self) -> f64
  • pub fn exp(self) -> f64

    e^self.

  • pub fn exp2(self) -> f64

    2^self.

  • pub fn exp_m1(self) -> f64

    e^self - 1, exact near zero.

  • pub fn ln(self) -> f64

    Natural logarithm.

  • pub fn ln_1p(self) -> f64

    ln(1 + self), exact near zero.

  • pub fn log2(self) -> f64
  • pub fn log10(self) -> f64
  • pub fn sin(self) -> f64
  • pub fn cos(self) -> f64
  • pub fn tan(self) -> f64
  • pub fn asin(self) -> f64
  • pub fn acos(self) -> f64
  • pub fn atan(self) -> f64
  • pub fn sinh(self) -> f64
  • pub fn cosh(self) -> f64
  • pub fn tanh(self) -> f64
  • pub fn asinh(self) -> f64
  • pub fn acosh(self) -> f64
  • pub fn atanh(self) -> f64
  • pub const fn fract(self) -> f64

    self - self.trunc().

  • pub const fn signum(self) -> f64

    -1.0 / 1.0 by sign; zeros and NaN are returned as they are (spec 2.1.4: -1.0, 0.0, or 1.0).

  • pub const fn recip(self) -> f64
  • pub const fn to_degrees(self) -> f64
  • pub const fn to_radians(self) -> f64
  • pub fn log(self, base: f64) -> f64

    ln(self) / ln(base).

  • pub fn pow(self, exp: f64) -> f64

    self^exp (spec 2.1.4; powf in Rust).

  • pub fn atan2(self, other: f64) -> f64

    Angle of the point (other, self).

  • pub fn hypot(self, other: f64) -> f64

    sqrt(self² + other²) without overflow.

  • pub const fn copysign(self, sign: f64) -> f64

    self's magnitude with sign's sign.

  • pub const fn min(self, other: f64) -> f64

    The smaller; a NaN operand loses to a number.

  • pub const fn max(self, other: f64) -> f64

    The larger; a NaN operand loses to a number.

  • pub fn powf(self, exp: f64) -> f64
  • pub fn powi(self, n: i32) -> f64
  • pub const fn mul_add(self, a: f64, b: f64) -> f64

    self * a + b with one rounding.

  • pub const fn clamp(self, lo: f64, hi: f64) -> f64

    self limited to lo..=hi; NaN stays NaN.

  • pub const fn div_euclid(self, rhs: f64) -> f64
  • pub const fn rem_euclid(self, rhs: f64) -> f64

impl f32

  • pub const EPSILON: f32 = 1.1920929e-7
  • pub const MAX: f32 = 3.40282347e38
  • pub const MIN: f32 = -3.40282347e38
  • pub const MIN_POSITIVE: f32 = 1.17549435e-38
  • pub const NAN: f32 = 0.0 / 0.0
  • pub const INFINITY: f32 = 1.0 / 0.0
  • pub const NEG_INFINITY: f32 = -1.0 / 0.0
  • pub const PI: f32 = 3.14159265358979323846264338327950288
  • pub const TAU: f32 = 6.28318530717958647692528676655900577
  • pub const E: f32 = 2.71828182845904523536028747135266250
  • pub const FRAC_PI_2: f32 = 1.57079632679489661923132169163975144
  • pub const FRAC_PI_4: f32 = 0.785398163397448309615660845819875721
  • pub const FRAC_1_PI: f32 = 0.318309886183790671537767526745028724
  • pub const SQRT_2: f32 = 1.41421356237309504880168872420969808
  • pub const FRAC_1_SQRT_2: f32 = 0.707106781186547524400844362104849039
  • pub const LN_2: f32 = 0.693147180559945309417232121458176568
  • pub const LN_10: f32 = 2.30258509299404568401799145468436421
  • pub const LOG2_E: f32 = 1.44269504088896340735992468100189214
  • pub const LOG10_E: f32 = 0.434294481903251827651128918916605082
  • pub const fn nan() -> f32
  • pub const fn infinity() -> f32
  • pub const fn neg_infinity() -> f32
  • pub const fn epsilon() -> f32

    The gap between 1.0 and the next f32 (EPSILON).

  • pub const fn to_bits(self) -> u32

    The IEEE 754 bit pattern.

  • pub const fn from_bits(bits: u32) -> f32
  • pub const fn is_nan(self) -> bool
  • pub const fn is_infinite(self) -> bool
  • pub const fn is_finite(self) -> bool
  • pub const fn is_normal(self) -> bool

    Neither zero, subnormal, infinite nor NaN.

  • pub const fn is_sign_positive(self) -> bool
  • pub const fn is_sign_negative(self) -> bool
  • pub const fn floor(self) -> f32

    Largest integer <= self.

  • pub const fn ceil(self) -> f32

    Smallest integer >= self.

  • pub const fn round(self) -> f32

    Nearest integer, halves away from zero.

  • pub const fn trunc(self) -> f32

    Integer part (toward zero).

  • pub const fn abs(self) -> f32
  • pub fn cbrt(self) -> f32
  • pub fn exp(self) -> f32

    e^self.

  • pub fn exp2(self) -> f32

    2^self.

  • pub fn exp_m1(self) -> f32

    e^self - 1, exact near zero.

  • pub fn ln(self) -> f32

    Natural logarithm.

  • pub fn ln_1p(self) -> f32

    ln(1 + self), exact near zero.

  • pub fn log2(self) -> f32
  • pub fn log10(self) -> f32
  • pub fn sin(self) -> f32
  • pub fn cos(self) -> f32
  • pub fn tan(self) -> f32
  • pub fn asin(self) -> f32
  • pub fn acos(self) -> f32
  • pub fn atan(self) -> f32
  • pub fn sinh(self) -> f32
  • pub fn cosh(self) -> f32
  • pub fn tanh(self) -> f32
  • pub fn asinh(self) -> f32
  • pub fn acosh(self) -> f32
  • pub fn atanh(self) -> f32
  • pub const fn fract(self) -> f32

    self - self.trunc().

  • pub const fn signum(self) -> f32

    -1.0 / 1.0 by sign; zeros and NaN are returned as they are (spec 2.1.4: -1.0, 0.0, or 1.0).

  • pub const fn recip(self) -> f32
  • pub const fn to_degrees(self) -> f32
  • pub const fn to_radians(self) -> f32
  • pub fn log(self, base: f32) -> f32

    ln(self) / ln(base).

  • pub fn pow(self, exp: f32) -> f32

    self^exp (spec 2.1.4; powf in Rust).

  • pub fn atan2(self, other: f32) -> f32

    Angle of the point (other, self).

  • pub fn hypot(self, other: f32) -> f32

    sqrt(self² + other²) without overflow.

  • pub const fn copysign(self, sign: f32) -> f32

    self's magnitude with sign's sign.

  • pub const fn min(self, other: f32) -> f32

    The smaller; a NaN operand loses to a number.

  • pub const fn max(self, other: f32) -> f32

    The larger; a NaN operand loses to a number.

  • pub fn powf(self, exp: f32) -> f32
  • pub fn powi(self, n: i32) -> f32
  • pub const fn mul_add(self, a: f32, b: f32) -> f32

    self * a + b with one rounding.

  • pub const fn clamp(self, lo: f32, hi: f32) -> f32

    self limited to lo..=hi; NaN stays NaN.

  • pub const fn div_euclid(self, rhs: f32) -> f32
  • pub const fn rem_euclid(self, rhs: f32) -> f32