pub enum DecomposeResult {
Normal {
is_neg: bool,
exp: i32,
mantissa: u128,
},
Zero,
NegZero,
Infinity,
NegInfinity,
NotANumber,
}Expand description
It’s literally DecomposeResult, not a number. If it were a number,
Zero and NegZero has to be equal. But they’re not equal because they’re
results of decompositions of different bit patterns.
Also, that’s why it implements Eq but not Ord.
Variants§
Normal
n = (-1)^is_neg * 2^exp * mantissa / 2^127
always 2^127 <= mantissa < 2^128
Zero
NegZero
Infinity
NegInfinity
NotANumber
It treats NaNs equal, and that’s intentional. IEEE754 treats NaNs unequal because
NaN is an indicator of an invalid operation. Here, DecomposeResult::NotANumber is
a result of a successful n.decompose(), so it has to implement Eq.
Trait Implementations§
Source§impl Clone for DecomposeResult
impl Clone for DecomposeResult
Source§fn clone(&self) -> DecomposeResult
fn clone(&self) -> DecomposeResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DecomposeResult
impl Debug for DecomposeResult
Source§impl Display for DecomposeResult
impl Display for DecomposeResult
Source§impl From<DecomposeResult> for f32
It implements From<DecomposeResult>, not TryFrom<DecomposeResult>.
If DecomposeResult is too big, it returns INFINITY or NEG_INFINITY instead
of throwing an overflow error. If it’s too small, it returns 0.0 or -0.0 instead
of throwing an underflow error.
impl From<DecomposeResult> for f32
It implements From<DecomposeResult>, not TryFrom<DecomposeResult>.
If DecomposeResult is too big, it returns INFINITY or NEG_INFINITY instead
of throwing an overflow error. If it’s too small, it returns 0.0 or -0.0 instead
of throwing an underflow error.
Source§fn from(r: DecomposeResult) -> f32
fn from(r: DecomposeResult) -> f32
Source§impl From<DecomposeResult> for f64
It implements From<DecomposeResult>, not TryFrom<DecomposeResult>.
If DecomposeResult is too big, it returns INFINITY or NEG_INFINITY instead
of throwing an overflow error. If it’s too small, it returns 0.0 or -0.0 instead
of throwing an underflow error.
impl From<DecomposeResult> for f64
It implements From<DecomposeResult>, not TryFrom<DecomposeResult>.
If DecomposeResult is too big, it returns INFINITY or NEG_INFINITY instead
of throwing an overflow error. If it’s too small, it returns 0.0 or -0.0 instead
of throwing an underflow error.