rokdocs
v0.1

rok::core::num::bigfloat

rok::core::num::bigfloat: float (stdlib 2.1.3). #[keyword("float")] routes the type name here; an unsuffixed literal in a float slot is Float::from_f64, or Float::from_literal when f64 can't hold it.

A float has f64's 53-bit significand and an i64 exponent (2.1.3 leaves the precision open). In f64's normal range it is an f64 (e == 0) with IEEE 754 operations. A finite result outside that range is promoted to m * 2^e, 1 <= |m| < 2, rounded to nearest-even instead of becoming ±inf / 0 / subnormal, so arithmetic never overflows; only / 0 and inf / NaN operands give inf / NaN.

Structs

Float

pub struct Float

m * 2^e. e == 0: m is the value (zero, normal, inf or NaN, never subnormal). e != 0: 1 <= |m| < 2 and e is outside f64's normal exponents -1022..=1023.

  • pub const fn from_f64(x: f64) -> Float
  • pub const fn from_f32(x: f32) -> Float
  • 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_zero(self) -> bool
  • pub const fn is_sign_negative(self) -> bool
  • pub const fn abs(self) -> Float
  • pub const fn to_f64(self) -> f64

    The nearest f64: ±inf past f64::MAX, ties to even into the subnormals, ±0 below them.

  • pub const fn to_f32(self) -> f32 | none

    none when a finite value is past f32's range (spec 2.1.3 leaves precision loss open: it rounds).

  • pub fn from_int(n: Int) -> Float

    The nearest float to n (ties to even).

  • pub const fn to_int(self) -> Int | none

    Truncated toward zero; none for NaN / ±inf.

  • pub fn try_parse(s: str) -> Float | none

    s as a decimal (-1.5e400, .5, inf, nan), correctly rounded; none when it isn't one. Decimal exponents past ±10^6 are none: the exact conversion would need a million-digit power of ten.

  • pub fn from_literal(s: str) -> Float

    An unsuffixed float literal (_ allowed) too large or small for f64 in a float slot.

Trait implementations 19
  • impl Add for Float
  • impl Sub for Float
  • impl Mul for Float
  • impl Div for Float
  • impl Rem for Float
  • impl Modulo for Float
  • impl Neg for Float
  • impl PartialEq for Float
  • impl PartialOrd for Float
  • impl Clone for Float
  • impl Copy for Float
  • impl Default for Float
  • impl Zero for Float
  • impl One for Float
  • impl Display for Float
  • impl Debug for Float
  • impl FromStr for Float
  • impl From<f32> for Float
  • impl From<f64> for Float