pub struct Decimal {
pub exponent: i64,
pub mantissa: u64,
pub negative: bool,
pub many_digits: bool,
}
🔬This is a nightly-only experimental API. (
dec2flt
)Expand description
A floating point number with up to 64 bits of mantissa and an i64
exponent.
Fields§
§exponent: i64
🔬This is a nightly-only experimental API. (
§dec2flt
)mantissa: u64
🔬This is a nightly-only experimental API. (
§dec2flt
)negative: bool
🔬This is a nightly-only experimental API. (
§dec2flt
)many_digits: bool
🔬This is a nightly-only experimental API. (
dec2flt
)Implementations§
Source§impl Decimal
impl Decimal
Sourcefn can_use_fast_path<F: RawFloat>(&self) -> bool
🔬This is a nightly-only experimental API. (dec2flt
)
fn can_use_fast_path<F: RawFloat>(&self) -> bool
dec2flt
)Detect if the float can be accurately reconstructed from native floats.
Sourcepub fn try_fast_path<F: RawFloat>(&self) -> Option<F>
🔬This is a nightly-only experimental API. (dec2flt
)
pub fn try_fast_path<F: RawFloat>(&self) -> Option<F>
dec2flt
)Try turning the decimal into an exact float representation, using machine-sized integers and floats.
This is extracted into a separate function so that it can be attempted before constructing a Decimal. This only works if both the mantissa and the exponent can be exactly represented as a machine float, since IEE-754 guarantees no rounding will occur.
There is an exception: disguised fast-path cases, where we can shift powers-of-10 from the exponent to the significant digits.
Trait Implementations§
impl Copy for Decimal
impl StructuralPartialEq for Decimal
Auto Trait Implementations§
impl Freeze for Decimal
impl RefUnwindSafe for Decimal
impl Send for Decimal
impl Sync for Decimal
impl Unpin for Decimal
impl UnsafeUnpin for Decimal
impl UnwindSafe for Decimal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)The largest safe length for a
[Self]
. Read more