pub struct RationalInteger { /* private fields */ }Implementations§
Source§impl RationalInteger
impl RationalInteger
pub fn try_new(numer: BigInt, denom: BigInt) -> Result<Self, NumericFailure>
pub fn from_i64_pair(numer: i64, denom: i64) -> Self
Sourcepub fn from_bigint_strings(
numer_str: &str,
denom_str: &str,
) -> Result<Self, NumericFailure>
pub fn from_bigint_strings( numer_str: &str, denom_str: &str, ) -> Result<Self, NumericFailure>
Construct from string-parsed BigInts (used by SerializedFactor round-trip).
pub fn is_integer(&self) -> bool
pub fn numer_is_zero(&self) -> bool
pub fn numer_is_positive(&self) -> bool
pub fn numer_is_negative(&self) -> bool
pub fn numer_to_i32(&self) -> Option<i32>
pub fn numer_to_i128(&self) -> Option<i128>
pub fn numer_to_u8(&self) -> Option<u8>
pub fn numer_to_usize(&self) -> Option<usize>
pub fn numer_to_string(&self) -> String
pub fn denom_to_string(&self) -> String
Sourcepub fn numer_magnitude_bits(&self) -> u64
pub fn numer_magnitude_bits(&self) -> u64
Exact bit length of the numerator’s magnitude; 0 for zero.
Sourcepub fn denom_magnitude_bits(&self) -> u64
pub fn denom_magnitude_bits(&self) -> u64
Exact bit length of the denominator’s magnitude.
pub fn try_reduce_ref( rational: &RationalInteger, ) -> Result<Self, NumericFailure>
pub fn try_reduce(self) -> Result<Self, NumericFailure>
pub fn try_cmp(&self, other: &Self) -> Result<Ordering, NumericFailure>
Sourcepub fn try_to_decimal(&self) -> Result<Decimal, NumericFailure>
pub fn try_to_decimal(&self) -> Result<Decimal, NumericFailure>
Round to Decimal::MAX_SCALE precision.
Returns NumericFailure::Overflow only when |self| > Decimal::MAX.
All RationalInteger values are constructed in reduced form, so no
re-reduction is needed here.
pub fn try_to_decimal_string(&self) -> Result<String, NumericFailure>
Sourcepub fn display_str(&self) -> String
pub fn display_str(&self) -> String
Human-readable decimal when try_to_decimal succeeds; fraction string on magnitude overflow.
Trait Implementations§
Source§impl Clone for RationalInteger
impl Clone for RationalInteger
Source§impl Debug for RationalInteger
impl Debug for RationalInteger
Source§impl Display for RationalInteger
impl Display for RationalInteger
impl Eq for RationalInteger
Source§impl Hash for RationalInteger
impl Hash for RationalInteger
Auto Trait Implementations§
impl Forget for RationalInteger
impl Freeze for RationalInteger
impl RefUnwindSafe for RationalInteger
impl Send for RationalInteger
impl Sync for RationalInteger
impl Unpin for RationalInteger
impl UnsafeUnpin for RationalInteger
impl UnwindSafe for RationalInteger
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> 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.