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 zero() -> Self
pub fn is_zero(&self) -> bool
pub fn is_positive(&self) -> bool
pub fn is_negative(&self) -> bool
pub fn decimal_type(&self) -> Option<DecimalDatatype>
pub fn lexical_representation(&self) -> &DecimalBuf
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 Ord for Decimal
impl Ord for Decimal
source§impl PartialEq<Decimal> for Decimal
impl PartialEq<Decimal> for Decimal
source§impl PartialOrd<Decimal> for Decimal
impl PartialOrd<Decimal> for Decimal
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl TryFrom<Ratio<BigInt>> for Decimal
impl TryFrom<Ratio<BigInt>> for Decimal
§type Error = NoDecimalRepresentation
type Error = NoDecimalRepresentation
The type returned in the event of a conversion error.