pub struct Decimal<T: Copy + Integer> { /* private fields */ }
Implementations§
Source§impl<T: Copy + Integer + FromPrimitive + ToPrimitive> Decimal<T>
impl<T: Copy + Integer + FromPrimitive + ToPrimitive> Decimal<T>
Sourcepub fn from_parts(mantissa: T, exponent: Exp) -> Decimal<T>
pub fn from_parts(mantissa: T, exponent: Exp) -> Decimal<T>
Create Decimal from mantissa and exponent.
Sourcepub fn round(&self) -> Decimal<T>
pub fn round(&self) -> Decimal<T>
Rounds to nearest integer. Half-way cases are rounded away from zero. Doesn’t alter precision.
Sourcepub fn to_f64(&self) -> f64
pub fn to_f64(&self) -> f64
Convert to f64, possibly with precision loss and overflows. Currently conversion isn’t perfect, i. e. it may be inexact even when exact conversion is possible.
Sourcepub fn to_f32(&self) -> f32
pub fn to_f32(&self) -> f32
Convert to f32, possibly with precision loss and overflows. Currently conversion isn’t perfect, i. e. it may be inexact even when exact conversion is possible.
Sourcepub fn to_int<U: Clone + Integer + FromPrimitive + From<T>>(&self) -> U
pub fn to_int<U: Clone + Integer + FromPrimitive + From<T>>(&self) -> U
Convert to an integer, truncating fractional part. May overflow.
pub fn canonical(&self) -> Decimal<T>
Trait Implementations§
Source§impl<T> AddAssign for Decimal<T>
impl<T> AddAssign for Decimal<T>
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+=
operation. Read moreSource§impl<'de, T> Deserialize<'de> for Decimal<T>
impl<'de, T> Deserialize<'de> for Decimal<T>
Source§fn deserialize<D>(deserializer: D) -> Result<Decimal<T>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Decimal<T>, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Num for Decimal<T>
impl<T> Num for Decimal<T>
type FromStrRadixErr = DecimalFromStrRadixErr
Source§fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
Convert from a string and radix (typically
2..=36
). Read moreSource§impl<T> Ord for Decimal<T>
impl<T> Ord for Decimal<T>
Source§impl<T> PartialOrd for Decimal<T>
impl<T> PartialOrd for Decimal<T>
Source§impl<T> Signed for Decimal<T>
impl<T> Signed for Decimal<T>
Source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Returns true if the number is positive and false if the number is zero or negative.
Source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Returns true if the number is negative and false if the number is zero or positive.
impl<T: Copy + Copy + Integer> Copy for Decimal<T>
impl<T> Eq for Decimal<T>
Auto Trait Implementations§
impl<T> Freeze for Decimal<T>where
T: Freeze,
impl<T> RefUnwindSafe for Decimal<T>where
T: RefUnwindSafe,
impl<T> Send for Decimal<T>where
T: Send,
impl<T> Sync for Decimal<T>where
T: Sync,
impl<T> Unpin for Decimal<T>where
T: Unpin,
impl<T> UnwindSafe for Decimal<T>where
T: UnwindSafe,
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