pub struct Relaxed(/* private fields */);Expand description
An arbitrary precision rational number without strict reduction.
This struct is almost the same as RBig, except for that the numerator and the denominator are allowed to have common divisors other than a power of 2. This allows faster computation because Gcd is not required for each operation.
Since the representation is not canonicalized, Hash is not implemented for Relaxed.
Please use RBig if you want to store the rational number in a hash set, or use num_order::NumHash.
§Conversion from/to RBig
To convert from RBig, use RBig::relax(). To convert to RBig, use Relaxed::canonicalize().
Implementations§
source§impl Relaxed
impl Relaxed
sourcepub fn to_f32_fast(&self) -> f32
pub fn to_f32_fast(&self) -> f32
Convert the rational number to a f32.
See RBig::to_f32_fast for details.
sourcepub fn to_f64_fast(&self) -> f64
pub fn to_f64_fast(&self) -> f64
Convert the rational number to a f64.
See RBig::to_f64_fast for details.
sourcepub fn to_f32(&self) -> Approximation<f32, Sign>
pub fn to_f32(&self) -> Approximation<f32, Sign>
Convert the rational number to a f32 with guaranteed correct rounding.
See RBig::to_f32 for details.
sourcepub fn to_f64(&self) -> Approximation<f64, Sign>
pub fn to_f64(&self) -> Approximation<f64, Sign>
Convert the rational number to a f64 with guaranteed correct rounding.
See RBig::to_f64 for details.
sourcepub fn to_int(&self) -> Approximation<IBig, Relaxed>
pub fn to_int(&self) -> Approximation<IBig, Relaxed>
Convert the rational number to am IBig.
See RBig::to_int for details.
source§impl Relaxed
impl Relaxed
source§impl Relaxed
impl Relaxed
sourcepub fn from_str_radix(src: &str, radix: u32) -> Result<Relaxed, ParseError>
pub fn from_str_radix(src: &str, radix: u32) -> Result<Relaxed, ParseError>
Convert a string in a given base to Relaxed.
See RBig::from_str_radix for details.
sourcepub fn from_str_with_radix_prefix(
src: &str,
) -> Result<(Relaxed, u32), ParseError>
pub fn from_str_with_radix_prefix( src: &str, ) -> Result<(Relaxed, u32), ParseError>
Convert a string with optional radix prefixes to RBig, return the parsed integer and radix.
See RBig::from_str_with_radix_prefix for details.
source§impl Relaxed
impl Relaxed
sourcepub fn from_parts(numerator: IBig, denominator: UBig) -> Relaxed
pub fn from_parts(numerator: IBig, denominator: UBig) -> Relaxed
Create a rational number from a signed numerator and a signed denominator
See RBig::from_parts for details.
sourcepub fn into_parts(self) -> (IBig, UBig)
pub fn into_parts(self) -> (IBig, UBig)
Convert the rational number into (numerator, denumerator) parts.
See RBig::into_parts for details.
sourcepub fn from_parts_signed(numerator: IBig, denominator: IBig) -> Relaxed
pub fn from_parts_signed(numerator: IBig, denominator: IBig) -> Relaxed
Create a rational number from a signed numerator and a signed denominator
See RBig::from_parts_signed for details.
sourcepub const fn from_parts_const(
sign: Sign,
numerator: u128,
denominator: u128,
) -> Relaxed
pub const fn from_parts_const( sign: Sign, numerator: u128, denominator: u128, ) -> Relaxed
Create a rational number in a const context
See RBig::from_parts_const for details.
sourcepub fn numerator(&self) -> &IBig
pub fn numerator(&self) -> &IBig
Get the numerator of the rational number
See RBig::numerator for details.
sourcepub fn denominator(&self) -> &UBig
pub fn denominator(&self) -> &UBig
Get the denominator of the rational number
See RBig::denominator for details.
sourcepub fn canonicalize(self) -> RBig
pub fn canonicalize(self) -> RBig
sourcepub const fn is_zero(&self) -> bool
pub const fn is_zero(&self) -> bool
Check whether the number is 0
See RBig::is_zero for details.
sourcepub fn is_one(&self) -> bool
pub fn is_one(&self) -> bool
Check whether the number is 1
See RBig::is_one for details.
source§impl Relaxed
impl Relaxed
sourcepub fn split_at_point(self) -> (IBig, Relaxed)
pub fn split_at_point(self) -> (IBig, Relaxed)
Split the rational number into integral and fractional parts (split at the radix point).
See RBig::split_at_point for details.
sourcepub fn ceil(&self) -> IBig
pub fn ceil(&self) -> IBig
Compute the smallest integer that is greater than this number.
See RBig::ceil for details.
sourcepub fn floor(&self) -> IBig
pub fn floor(&self) -> IBig
Compute the largest integer that is less than or equal to this number.
See RBig::floor for details.
sourcepub fn round(&self) -> IBig
pub fn round(&self) -> IBig
Compute the integer that closest to this number.
See RBig::round for details.
sourcepub fn trunc(&self) -> IBig
pub fn trunc(&self) -> IBig
Returns the integral part of the rational number.
See RBig::trunc for details.
sourcepub fn fract(&self) -> Relaxed
pub fn fract(&self) -> Relaxed
Returns the fractional part of the rational number
See RBig::fract for details.
Trait Implementations§
source§impl AddAssign<&Relaxed> for Relaxed
impl AddAssign<&Relaxed> for Relaxed
source§fn add_assign(&mut self, rhs: &Relaxed)
fn add_assign(&mut self, rhs: &Relaxed)
+= operation. Read moresource§impl AddAssign for Relaxed
impl AddAssign for Relaxed
source§fn add_assign(&mut self, rhs: Relaxed)
fn add_assign(&mut self, rhs: Relaxed)
+= operation. Read moresource§impl DivAssign<&Relaxed> for Relaxed
impl DivAssign<&Relaxed> for Relaxed
source§fn div_assign(&mut self, rhs: &Relaxed)
fn div_assign(&mut self, rhs: &Relaxed)
/= operation. Read moresource§impl DivAssign for Relaxed
impl DivAssign for Relaxed
source§fn div_assign(&mut self, rhs: Relaxed)
fn div_assign(&mut self, rhs: Relaxed)
/= operation. Read moresource§impl<'l, 'r> DivRemEuclid<&'r Relaxed> for &'l Relaxed
impl<'l, 'r> DivRemEuclid<&'r Relaxed> for &'l Relaxed
source§impl<'r> DivRemEuclid<&'r Relaxed> for Relaxed
impl<'r> DivRemEuclid<&'r Relaxed> for Relaxed
source§impl<'l> DivRemEuclid<Relaxed> for &'l Relaxed
impl<'l> DivRemEuclid<Relaxed> for &'l Relaxed
source§impl DivRemEuclid for Relaxed
impl DivRemEuclid for Relaxed
source§impl EstimatedLog2 for Relaxed
impl EstimatedLog2 for Relaxed
source§impl MulAssign<&Relaxed> for Relaxed
impl MulAssign<&Relaxed> for Relaxed
source§fn mul_assign(&mut self, rhs: &Relaxed)
fn mul_assign(&mut self, rhs: &Relaxed)
*= operation. Read moresource§impl MulAssign for Relaxed
impl MulAssign for Relaxed
source§fn mul_assign(&mut self, rhs: Relaxed)
fn mul_assign(&mut self, rhs: Relaxed)
*= operation. Read moresource§impl<R, const B: u64> NumOrd<FBig<R, B>> for Relaxedwhere
R: Round,
impl<R, const B: u64> NumOrd<FBig<R, B>> for Relaxedwhere
R: Round,
source§impl NumOrd<IBig> for Relaxed
impl NumOrd<IBig> for Relaxed
source§impl NumOrd<RBig> for Relaxed
impl NumOrd<RBig> for Relaxed
source§impl<R, const B: u64> NumOrd<Relaxed> for FBig<R, B>where
R: Round,
impl<R, const B: u64> NumOrd<Relaxed> for FBig<R, B>where
R: Round,
source§impl NumOrd<Relaxed> for IBig
impl NumOrd<Relaxed> for IBig
source§impl NumOrd<Relaxed> for RBig
impl NumOrd<Relaxed> for RBig
source§impl NumOrd<Relaxed> for UBig
impl NumOrd<Relaxed> for UBig
source§impl NumOrd<UBig> for Relaxed
impl NumOrd<UBig> for Relaxed
source§impl NumOrd<f32> for Relaxed
impl NumOrd<f32> for Relaxed
source§impl NumOrd<f64> for Relaxed
impl NumOrd<f64> for Relaxed
source§impl NumOrd<i128> for Relaxed
impl NumOrd<i128> for Relaxed
source§impl NumOrd<i16> for Relaxed
impl NumOrd<i16> for Relaxed
source§impl NumOrd<i32> for Relaxed
impl NumOrd<i32> for Relaxed
source§impl NumOrd<i64> for Relaxed
impl NumOrd<i64> for Relaxed
source§impl NumOrd<i8> for Relaxed
impl NumOrd<i8> for Relaxed
source§impl NumOrd<isize> for Relaxed
impl NumOrd<isize> for Relaxed
source§impl NumOrd<u128> for Relaxed
impl NumOrd<u128> for Relaxed
source§impl NumOrd<u16> for Relaxed
impl NumOrd<u16> for Relaxed
source§impl NumOrd<u32> for Relaxed
impl NumOrd<u32> for Relaxed
source§impl NumOrd<u64> for Relaxed
impl NumOrd<u64> for Relaxed
source§impl NumOrd<u8> for Relaxed
impl NumOrd<u8> for Relaxed
source§impl NumOrd<usize> for Relaxed
impl NumOrd<usize> for Relaxed
source§impl Ord for Relaxed
impl Ord for Relaxed
source§impl PartialEq for Relaxed
impl PartialEq for Relaxed
source§impl PartialOrd for Relaxed
impl PartialOrd for Relaxed
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl RemAssign<&Relaxed> for Relaxed
impl RemAssign<&Relaxed> for Relaxed
source§fn rem_assign(&mut self, rhs: &Relaxed)
fn rem_assign(&mut self, rhs: &Relaxed)
%= operation. Read moresource§impl RemAssign for Relaxed
impl RemAssign for Relaxed
source§fn rem_assign(&mut self, rhs: Relaxed)
fn rem_assign(&mut self, rhs: Relaxed)
%= operation. Read moresource§impl SubAssign<&Relaxed> for Relaxed
impl SubAssign<&Relaxed> for Relaxed
source§fn sub_assign(&mut self, rhs: &Relaxed)
fn sub_assign(&mut self, rhs: &Relaxed)
-= operation. Read moresource§impl SubAssign for Relaxed
impl SubAssign for Relaxed
source§fn sub_assign(&mut self, rhs: Relaxed)
fn sub_assign(&mut self, rhs: Relaxed)
-= operation. Read more