pub struct F56(pub [u8; 7]);
Expand description
The F56 struct represents a 56-bit floating point number using 7 bytes. Most operations on F56 are done by converting to f64, performing the operation, and then converting back to F56
F56 uses 1 bit for the sign, 10 bits for the exponent, and 45 bits for the mantissa. Compared to f32, it has +2 exponent bits and +22 mantissa bits. Compared to f64, it has -1 exponent bit and -7 mantissa bits. Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 [sEEEEEEE][EEEmmmmm][mmmmmmmm][mmmmmmmm][mmmmmmmm][mmmmmmmm][mmmmmmmm]]
Exponent bits range from 0 to 1023 they represent -511 to +512 but are stored biased by +511 the exponent of -511 is reserved for the number 0 and subnormal numbers the exponent of +512 is reserved for infinity and NaN so normal exponents range from -510 to +511
smallest positive subnormal value is 8.48e-168 (2^-555) smallest positive normal value is 2.98e-154 (2^-510) maximum finite value is 1.34e154
A f64 number like 1.00000000001 with 12 decimal digits will be 1.000000000001 A f64 number like 1.000000000001 with 13 decimal digits will be converted to 1.0
Tuple Fields§
§0: [u8; 7]
Implementations§
Source§impl F56
impl F56
pub fn round_f64_to_7_sig_figs(raw_f64: f64) -> f64
pub fn round_f64_to_f56_precision(raw_f64: f64) -> f64
Sourcepub fn roughly_equal_using_rounding_sig_figs(&self, other: &F56) -> bool
pub fn roughly_equal_using_rounding_sig_figs(&self, other: &F56) -> bool
Returns true if the two F56s’s decimal forms are equal to 7 significant figures This is a lenient type of equality suitable for human use It preserves transitivity, reflexivity, and symmetry It meets the requirements of the Eq trait
Sourcepub fn roughly_equal_using_relative_difference(&self, other: &F56) -> bool
pub fn roughly_equal_using_relative_difference(&self, other: &F56) -> bool
Returns true if the relative difference between the two F56s is less than F56::EPSILON This is a lenient type of equality suitable for human use It preserves reflexivity, and symmetry but not transitivity It does not meet the requirements of the Eq trait The relative difference is the absolute difference divided by the larger of the two numbers
Sourcepub fn strictest_equal(&self, other: &F56) -> bool
pub fn strictest_equal(&self, other: &F56) -> bool
Returns true if the two F56s are bitwise identical
pub fn hash_for_strictest_equal(&self) -> u64
Sourcepub fn strictly_equal_except_nan_and_0(&self, other: &F56) -> bool
pub fn strictly_equal_except_nan_and_0(&self, other: &F56) -> bool
Returns true if the two F56s are bitwise identical OR if they are both NaN or both 0