pub struct HexSignificand { /* private fields */ }Expand description
A C99 hex float’s significand, accumulated exactly.
The value is m * 2^e2, plus a non-zero tail below m’s window when
sticky is set. m holds up to 60 bits, well past f64’s 53 plus the
guard and round bits, so the sticky tail is all the rounding needs.
Implementations§
Source§impl HexSignificand
impl HexSignificand
pub fn new() -> Self
Sourcepub fn push_digit(&mut self, digit: u8, fractional: bool)
pub fn push_digit(&mut self, digit: u8, fractional: bool)
Fold in one hex digit. fractional marks the digits after the .,
which lower the exponent instead of raising the value.
Sourcepub fn apply_binary_exponent(&mut self, exp: i32)
pub fn apply_binary_exponent(&mut self, exp: i32)
Apply the p<exp> binary exponent.
Sourcepub fn to_f64(&self) -> (f64, bool)
pub fn to_f64(&self) -> (f64, bool)
Round to the nearest f64 (ties to even) and report errno == ERANGE.
glibc sets ERANGE when the result overflows to infinity, and when the
EXACT value is tiny (below the smallest normal, 2^-1022) and the
conversion is inexact. Note both halves: 0x1p-1074 is tiny but exact
(no ERANGE), and 0x1.fffffffffffffp-1023 is tiny-and-inexact yet
rounds up to the smallest normal — ERANGE all the same, because the
test is on the value before rounding.
Trait Implementations§
Source§impl Clone for HexSignificand
impl Clone for HexSignificand
Source§fn clone(&self) -> HexSignificand
fn clone(&self) -> HexSignificand
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more