Trait lexical_util::num::Float
source · pub trait Float: Number + Neg<Output = Self> {
type Unsigned: UnsignedInteger;
Show 21 associated constants and 22 methods
const ZERO: Self;
const ONE: Self;
const TWO: Self;
const MAX: Self;
const MIN: Self;
const INFINITY: Self;
const NEG_INFINITY: Self;
const NAN: Self;
const BITS: usize;
const SIGN_MASK: Self::Unsigned;
const EXPONENT_MASK: Self::Unsigned;
const HIDDEN_BIT_MASK: Self::Unsigned;
const MANTISSA_MASK: Self::Unsigned;
const CARRY_MASK: Self::Unsigned;
const INFINITY_BITS: Self::Unsigned;
const NEGATIVE_INFINITY_BITS: Self::Unsigned;
const EXPONENT_SIZE: i32;
const MANTISSA_SIZE: i32;
const EXPONENT_BIAS: i32;
const DENORMAL_EXPONENT: i32;
const MAX_EXPONENT: i32;
// Required methods
fn to_bits(self) -> Self::Unsigned;
fn from_bits(u: Self::Unsigned) -> Self;
fn ln(self) -> Self;
fn floor(self) -> Self;
fn is_sign_positive(self) -> bool;
fn is_sign_negative(self) -> bool;
// Provided methods
fn is_denormal(self) -> bool { ... }
fn is_special(self) -> bool { ... }
fn is_nan(self) -> bool { ... }
fn is_inf(self) -> bool { ... }
fn is_odd(self) -> bool { ... }
fn is_even(self) -> bool { ... }
fn needs_negative_sign(self) -> bool { ... }
fn exponent(self) -> i32 { ... }
fn mantissa(self) -> Self::Unsigned { ... }
fn next(self) -> Self { ... }
fn next_positive(self) -> Self { ... }
fn prev(self) -> Self { ... }
fn prev_positive(self) -> Self { ... }
fn round_positive_even(self) -> Self { ... }
fn max_finite(self, f: Self) -> Self { ... }
fn min_finite(self, f: Self) -> Self { ... }
}
Expand description
Float information for native float types.
Required Associated Types§
sourcetype Unsigned: UnsignedInteger
type Unsigned: UnsignedInteger
Unsigned type of the same size.
Required Associated Constants§
const ZERO: Self
const ONE: Self
const TWO: Self
const MAX: Self
const MIN: Self
const INFINITY: Self
const NEG_INFINITY: Self
const NAN: Self
const BITS: usize
sourceconst EXPONENT_MASK: Self::Unsigned
const EXPONENT_MASK: Self::Unsigned
Bitmask for the exponent, including the hidden bit.
sourceconst HIDDEN_BIT_MASK: Self::Unsigned
const HIDDEN_BIT_MASK: Self::Unsigned
Bitmask for the hidden bit in exponent, which is an implicit 1 in the fraction.
sourceconst MANTISSA_MASK: Self::Unsigned
const MANTISSA_MASK: Self::Unsigned
Bitmask for the mantissa (fraction), excluding the hidden bit.
sourceconst CARRY_MASK: Self::Unsigned
const CARRY_MASK: Self::Unsigned
Mask to determine if a full-carry occurred (1 in bit above hidden bit).
sourceconst INFINITY_BITS: Self::Unsigned
const INFINITY_BITS: Self::Unsigned
Positive infinity as bits.
sourceconst NEGATIVE_INFINITY_BITS: Self::Unsigned
const NEGATIVE_INFINITY_BITS: Self::Unsigned
Positive infinity as bits.
sourceconst EXPONENT_SIZE: i32
const EXPONENT_SIZE: i32
Size of the exponent.
sourceconst MANTISSA_SIZE: i32
const MANTISSA_SIZE: i32
Size of the significand (mantissa) without hidden bit.
sourceconst EXPONENT_BIAS: i32
const EXPONENT_BIAS: i32
Bias of the exponent.
sourceconst DENORMAL_EXPONENT: i32
const DENORMAL_EXPONENT: i32
Exponent portion of a denormal float.
sourceconst MAX_EXPONENT: i32
const MAX_EXPONENT: i32
Maximum exponent value in float.
Required Methods§
fn to_bits(self) -> Self::Unsigned
fn from_bits(u: Self::Unsigned) -> Self
fn ln(self) -> Self
fn floor(self) -> Self
fn is_sign_positive(self) -> bool
fn is_sign_negative(self) -> bool
Provided Methods§
sourcefn is_denormal(self) -> bool
fn is_denormal(self) -> bool
Returns true if the float is a denormal.
sourcefn is_special(self) -> bool
fn is_special(self) -> bool
Returns true if the float is a NaN or Infinite.
sourcefn needs_negative_sign(self) -> bool
fn needs_negative_sign(self) -> bool
Returns true if the float needs a negative sign when serializing it.
This is true if it’s -0.0
or it’s below 0 and not NaN. But inf values
need the sign.
sourcefn next_positive(self) -> Self
fn next_positive(self) -> Self
Get next greater float for a positive float. Value must be >= 0.0 and < INFINITY.
sourcefn prev_positive(self) -> Self
fn prev_positive(self) -> Self
Get previous greater float for a positive float. Value must be > 0.0.
sourcefn round_positive_even(self) -> Self
fn round_positive_even(self) -> Self
Round a positive number to even.
sourcefn max_finite(self, f: Self) -> Self
fn max_finite(self, f: Self) -> Self
Get the max of two finite numbers.
sourcefn min_finite(self, f: Self) -> Self
fn min_finite(self, f: Self) -> Self
Get the min of two finite numbers.