| 1 | //! Extended precision floating-point type. |
| 2 | //! |
| 3 | //! Also contains helpers to convert to and from native rust floats. |
| 4 | //! This representation stores the mantissa as a 64-bit unsigned integer, |
| 5 | //! and the exponent as a 32-bit unsigned integer, allowed ~80 bits of |
| 6 | //! precision (only 16 bits of the 32-bit integer are used, u32 is used |
| 7 | //! for performance). Since there is no storage for the sign bit, |
| 8 | //! this only works for positive floats. |
| 9 | |
| 10 | #![cfg(any(feature = "parse-floats", feature = "write-floats"))] |
| 11 | |
| 12 | use craterust-analyzer cargo lexical-util 1.0.7 crate/::numrust-analyzer cargo lexical-util 1.0.7 num/::UnsignedIntegerrust-analyzer cargo lexical-util 1.0.7 num/UnsignedInteger#; |
| 13 | |
| 14 | /// Extended precision floating-point type. |
| 15 | /// |
| 16 | /// This doesn't have any methods because it's used for **very** different |
| 17 | /// things for the Lemire, Bellepheron, and other algorithms. In Grisu, |
| 18 | /// it's an unbiased representation, for Lemire, it's a biased representation. |
| 19 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 20 | pub struct ExtendedFloatrust-analyzer cargo lexical-util 1.0.7 extended_float/ExtendedFloat#<M: UnsignedIntegerrust-analyzer cargo lexical-util 1.0.7 num/UnsignedInteger#> { |
| 21 | /// Mantissa for the extended-precision float. |
| 22 | pub mantrust-analyzer cargo lexical-util 1.0.7 extended_float/ExtendedFloat#mant.: M, |
| 23 | /// Binary exponent for the extended-precision float. |
| 24 | pub exprust-analyzer cargo lexical-util 1.0.7 extended_float/ExtendedFloat#exp.: i32, |
| 25 | } |
| 26 | |
| 27 | impl<M: UnsignedIntegerrust-analyzer cargo lexical-util 1.0.7 num/UnsignedInteger#> ExtendedFloatrust-analyzer cargo lexical-util 1.0.7 extended_float/ExtendedFloat#<M> { |
| 28 | /// Get the mantissa component. |
| 29 | #[inline(always)] |
| 30 | pub fn mantissarust-analyzer cargo lexical-util 1.0.7 extended_float/impl#[`ExtendedFloat<M>`]mantissa().(&self) -> M { |
| 31 | self.mantrust-analyzer cargo lexical-util 1.0.7 extended_float/ExtendedFloat#mant. |
| 32 | } |
| 33 | |
| 34 | /// Get the exponent component. |
| 35 | #[inline(always)] |
| 36 | pub fn exponentrust-analyzer cargo lexical-util 1.0.7 extended_float/impl#[`ExtendedFloat<M>`]exponent().(&self) -> i32 { |
| 37 | self.exprust-analyzer cargo lexical-util 1.0.7 extended_float/ExtendedFloat#exp. |
| 38 | } |
| 39 | } |