pub struct Decimal { /* private fields */ }
Expand description
Decimal number.
Internally a decimal number is represented as a BigRational
with a finite
decimal representation.
Implementations§
Source§impl Decimal
impl Decimal
Sourcepub unsafe fn new_unchecked(r: BigRational) -> Self
pub unsafe fn new_unchecked(r: BigRational) -> Self
Creates a new decimal number from a rational number.
§Safety
The input rational number must have a finite decimal representation.
pub fn as_big_rational(&self) -> &BigRational
pub fn into_big_rational(self) -> BigRational
pub fn zero() -> Self
pub fn is_zero(&self) -> bool
pub fn is_positive(&self) -> bool
pub fn is_negative(&self) -> bool
pub fn as_integer(&self) -> Option<&Integer>
pub fn into_integer(self) -> Option<Integer>
pub fn decimal_type(&self) -> DecimalDatatype
pub fn lexical_representation(&self) -> &DecimalBuf
pub fn as_f64(&self) -> Option<f64>
pub fn as_f32(&self) -> Option<f32>
pub fn as_float(&self) -> Option<Float>
pub fn as_double(&self) -> Option<Double>
Trait Implementations§
Source§impl AsRef<Ratio<BigInt>> for Decimal
impl AsRef<Ratio<BigInt>> for Decimal
Source§fn as_ref(&self) -> &BigRational
fn as_ref(&self) -> &BigRational
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl Borrow<Ratio<BigInt>> for Decimal
impl Borrow<Ratio<BigInt>> for Decimal
Source§fn borrow(&self) -> &BigRational
fn borrow(&self) -> &BigRational
Immutably borrows from an owned value. Read more
Source§impl From<Decimal> for BigRational
impl From<Decimal> for BigRational
Source§impl From<DecimalBuf> for Decimal
impl From<DecimalBuf> for Decimal
Source§fn from(value: DecimalBuf) -> Self
fn from(value: DecimalBuf) -> Self
Converts to this type from the input type.
Source§impl LexicalFormOf<Decimal> for Decimal
impl LexicalFormOf<Decimal> for Decimal
type ValueError = Infallible
fn try_as_value(&self) -> Result<Decimal, Self::ValueError>
fn as_value(&self) -> Vwhere
Self: LexicalFormOf<V, ValueError = Infallible>,
Source§impl Ord for Decimal
impl Ord for Decimal
Source§impl ParseXsd for Decimal
impl ParseXsd for Decimal
type LexicalForm = Decimal
fn parse_xsd(lexical_value: &str) -> ParseXsdResult<Self, Self::LexicalForm>
Source§impl PartialOrd for Decimal
impl PartialOrd for Decimal
Source§impl<'a> TryFrom<&'a Decimal> for i16
impl<'a> TryFrom<&'a Decimal> for i16
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for i32
impl<'a> TryFrom<&'a Decimal> for i32
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for i64
impl<'a> TryFrom<&'a Decimal> for i64
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for i8
impl<'a> TryFrom<&'a Decimal> for i8
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for isize
impl<'a> TryFrom<&'a Decimal> for isize
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for u16
impl<'a> TryFrom<&'a Decimal> for u16
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for u32
impl<'a> TryFrom<&'a Decimal> for u32
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for u64
impl<'a> TryFrom<&'a Decimal> for u64
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for u8
impl<'a> TryFrom<&'a Decimal> for u8
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl<'a> TryFrom<&'a Decimal> for usize
impl<'a> TryFrom<&'a Decimal> for usize
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for i16
impl TryFrom<Decimal> for i16
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for i32
impl TryFrom<Decimal> for i32
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for i64
impl TryFrom<Decimal> for i64
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for i8
impl TryFrom<Decimal> for i8
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for isize
impl TryFrom<Decimal> for isize
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for u16
impl TryFrom<Decimal> for u16
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for u32
impl TryFrom<Decimal> for u32
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for u64
impl TryFrom<Decimal> for u64
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for u8
impl TryFrom<Decimal> for u8
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Decimal> for usize
impl TryFrom<Decimal> for usize
Source§type Error = FromDecimalError
type Error = FromDecimalError
The type returned in the event of a conversion error.
Source§impl TryFrom<Ratio<BigInt>> for Decimal
impl TryFrom<Ratio<BigInt>> for Decimal
Source§type Error = NoDecimalRepresentation
type Error = NoDecimalRepresentation
The type returned in the event of a conversion error.
impl Eq 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 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