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