Trait lexical_util::num::Float
source · [−]pub trait Float: Number + Neg<Output = Self> {
type Unsigned: UnsignedInteger;
Show 21 associated constants and 21 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;
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;
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 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
Unsigned type of the same size.
Required Associated Constants
const NEG_INFINITY: Self
const EXPONENT_MASK: Self::Unsigned
const EXPONENT_MASK: Self::Unsigned
Bitmask for the exponent, including the hidden bit.
const 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.
const MANTISSA_MASK: Self::Unsigned
const MANTISSA_MASK: Self::Unsigned
Bitmask for the mantissa (fraction), excluding the hidden bit.
const CARRY_MASK: Self::Unsigned
const CARRY_MASK: Self::Unsigned
Mask to determine if a full-carry occurred (1 in bit above hidden bit).
const INFINITY_BITS: Self::Unsigned
const INFINITY_BITS: Self::Unsigned
Positive infinity as bits.
const NEGATIVE_INFINITY_BITS: Self::Unsigned
const NEGATIVE_INFINITY_BITS: Self::Unsigned
Positive infinity as bits.
const EXPONENT_SIZE: i32
const EXPONENT_SIZE: i32
Size of the exponent.
const MANTISSA_SIZE: i32
const MANTISSA_SIZE: i32
Size of the significand (mantissa) without hidden bit.
const EXPONENT_BIAS: i32
const EXPONENT_BIAS: i32
Bias of the exponent.
const DENORMAL_EXPONENT: i32
const DENORMAL_EXPONENT: i32
Exponent portion of a denormal float.
const MAX_EXPONENT: i32
const MAX_EXPONENT: i32
Maximum exponent value in float.
Required Methods
fn is_sign_positive(self) -> bool
fn is_sign_negative(self) -> bool
Provided Methods
fn is_denormal(self) -> bool
fn is_denormal(self) -> bool
Returns true if the float is a denormal.
fn is_special(self) -> bool
fn is_special(self) -> bool
Returns true if the float is a NaN or Infinite.
fn next_positive(self) -> Self
fn next_positive(self) -> Self
Get next greater float for a positive float. Value must be >= 0.0 and < INFINITY.
fn prev_positive(self) -> Self
fn prev_positive(self) -> Self
Get previous greater float for a positive float. Value must be > 0.0.
fn round_positive_even(self) -> Self
fn round_positive_even(self) -> Self
Round a positive number to even.
fn max_finite(self, f: Self) -> Self
fn max_finite(self, f: Self) -> Self
Get the max of two finite numbers.
fn min_finite(self, f: Self) -> Self
fn min_finite(self, f: Self) -> Self
Get the min of two finite numbers.