pub struct Decimal128 { /* private fields */ }
Expand description
Microsoft’s decimal128
Please note that this is NOT BSON compliant data.
This struct is only for storing / passing data, so most mathematical operations are not implemented (yet)
Implementations§
Source§impl Decimal128
impl Decimal128
pub const ZERO: Decimal128
pub const MAX: Decimal128
pub const MIN: Decimal128
Sourcepub const fn from_bytes(bytes: [u8; 16]) -> Option<Decimal128>
pub const fn from_bytes(bytes: [u8; 16]) -> Option<Decimal128>
Construct a new decimal128 from raw representation
Returns None if the representation is not valid
Sourcepub const fn new(mantissa: u128, exponent: u32, is_negative: bool) -> Decimal128
pub const fn new(mantissa: u128, exponent: u32, is_negative: bool) -> Decimal128
Construct a new decimal128 from raw parts
The result value would be
mantissa
* 10 ^ -exponent
* (if is_negative
{ -1 } else { 1 }) where ^ is power
§Panics
This function panics if:
- mantissa is greater than 1 << 96
- exponent is greater than 28
Sourcepub const fn new_signed(mantissa: i128, exponent: u32) -> Decimal128
pub const fn new_signed(mantissa: i128, exponent: u32) -> Decimal128
Construct a new decimal128 from raw parts with mantissa and exponent
The result value would be
mantissa
* 10 ^ -exponent
* (if is_negative
{ -1 } else { 1 }) where ^ is power
§Panics
This function panics if:
- mantissa is greater than 1 << 96
- exponent is greater than 28
Sourcepub const fn parse(s: &str) -> Option<Decimal128>
pub const fn parse(s: &str) -> Option<Decimal128>
Parses the string and converts to Decimal128.
Decimal is only supported.
pub fn bytes(&self) -> [u8; 16]
pub const fn is_negative(&self) -> bool
pub const fn abs(self) -> Self
pub fn round_digits(self, digits: u32) -> Self
pub fn to_f64(&self) -> f64
pub fn to_i64(&self) -> Option<i64>
pub fn to_i32(&self) -> Option<i32>
Trait Implementations§
Source§impl Add for Decimal128
impl Add for Decimal128
Source§impl Clone for Decimal128
impl Clone for Decimal128
Source§fn clone(&self) -> Decimal128
fn clone(&self) -> Decimal128
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Decimal128
impl Debug for Decimal128
Source§impl Display for Decimal128
impl Display for Decimal128
Source§impl Div for Decimal128
impl Div for Decimal128
Source§type Output = Decimal128
type Output = Decimal128
The resulting type after applying the
/
operator.Source§fn div(self, rhs: Decimal128) -> Decimal128
fn div(self, rhs: Decimal128) -> Decimal128
Performs the
/
operation. Read moreSource§impl From<Decimal128> for Value
impl From<Decimal128> for Value
Source§fn from(v: Decimal128) -> Value
fn from(v: Decimal128) -> Value
Converts to this type from the input type.
Source§impl From<i16> for Decimal128
impl From<i16> for Decimal128
Source§impl From<i32> for Decimal128
impl From<i32> for Decimal128
Source§impl From<i64> for Decimal128
impl From<i64> for Decimal128
Source§impl From<i8> for Decimal128
impl From<i8> for Decimal128
Source§impl From<u16> for Decimal128
impl From<u16> for Decimal128
Source§impl From<u32> for Decimal128
impl From<u32> for Decimal128
Source§impl From<u64> for Decimal128
impl From<u64> for Decimal128
Source§impl From<u8> for Decimal128
impl From<u8> for Decimal128
Source§impl Mul for Decimal128
impl Mul for Decimal128
Source§type Output = Decimal128
type Output = Decimal128
The resulting type after applying the
*
operator.Source§fn mul(self, rhs: Decimal128) -> Decimal128
fn mul(self, rhs: Decimal128) -> Decimal128
Performs the
*
operation. Read moreSource§impl Neg for Decimal128
impl Neg for Decimal128
Source§impl Ord for Decimal128
impl Ord for Decimal128
Source§impl PartialEq for Decimal128
impl PartialEq for Decimal128
Source§impl PartialOrd for Decimal128
impl PartialOrd for Decimal128
Source§impl Sub for Decimal128
impl Sub for Decimal128
Source§type Output = Decimal128
type Output = Decimal128
The resulting type after applying the
-
operator.Source§fn sub(self, rhs: Decimal128) -> Decimal128
fn sub(self, rhs: Decimal128) -> Decimal128
Performs the
-
operation. Read moreSource§impl TryFrom<f64> for Decimal128
impl TryFrom<f64> for Decimal128
impl Copy for Decimal128
impl Eq for Decimal128
Auto Trait Implementations§
impl Freeze for Decimal128
impl RefUnwindSafe for Decimal128
impl Send for Decimal128
impl Sync for Decimal128
impl Unpin for Decimal128
impl UnwindSafe for Decimal128
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more