Struct ExactRational
pub struct ExactRational(/* private fields */);Description
Exact reduced rational used by operator definitions and proofs.
Coefficients admit every finite binary64 value, including subnormals. Each numerator and denominator is limited to 8192 bits. Checked arithmetic rejects larger operands/results; executable arithmetic retains its original node order.
Implementations§
§impl ExactRational
impl ExactRational
pub fn from_binary64(value: f64) -> Option<ExactRational>
pub fn from_binary64(value: f64) -> Option<ExactRational>
Represent every finite binary64 value exactly as a reduced dyadic rational. Signed zeros have the same canonical rational value; nonfinite values reject.
§impl ExactRational
impl ExactRational
pub fn new(
numerator: i64,
denominator: i64,
) -> Result<ExactRational, PureOperatorError>
pub fn new( numerator: i64, denominator: i64, ) -> Result<ExactRational, PureOperatorError>
pub fn from_canonical_parts(
numerator: &str,
denominator: &str,
) -> Result<ExactRational, PureOperatorError>
pub fn from_canonical_parts( numerator: &str, denominator: &str, ) -> Result<ExactRational, PureOperatorError>
Reconstruct reduced canonical decimal parts without leading zeros or +.
§Errors
Rejects noncanonical spelling, a nonpositive denominator, unreduced ratios, and operands outside the arithmetic work budget before normalization.
pub fn append_canonical_bytes(&self, bytes: &mut Vec<u8>)
pub fn append_canonical_bytes(&self, bytes: &mut Vec<u8>)
Encode the same length-prefixed signed numerator and positive denominator for every exact-calculus identity owner.
pub fn from_decimal_parts(
coefficient: &str,
exponent: i64,
negative: bool,
) -> Result<ExactRational, PureOperatorError>
pub fn from_decimal_parts( coefficient: &str, exponent: i64, negative: bool, ) -> Result<ExactRational, PureOperatorError>
Exact nonnegative decimal coefficient times a signed power of ten.
§Errors
Rejects malformed coefficients or input/result sizes outside the work budget.
pub fn to_i32_ratio(&self) -> Option<(i32, i32)>
pub fn to_i32_ratio(&self) -> Option<(i32, i32)>
Checked conversion of both parts to signed 32-bit integers.
pub fn to_f64(&self) -> Result<f64, PureOperatorError>
pub fn to_f64(&self) -> Result<f64, PureOperatorError>
Correctly rounded binary64 coefficient for executable lowering.
§Errors
Rejects overflow and rounding a nonzero exact coefficient to zero.
pub fn checked_neg(&self) -> Result<ExactRational, PureOperatorError>
pub fn checked_neg(&self) -> Result<ExactRational, PureOperatorError>
Exact negation within the coefficient work budget.
pub fn checked_add(
&self,
other: ExactRational,
) -> Result<ExactRational, PureOperatorError>
pub fn checked_add( &self, other: ExactRational, ) -> Result<ExactRational, PureOperatorError>
Exact sum within the coefficient work budget.
pub fn checked_mul(
&self,
other: ExactRational,
) -> Result<ExactRational, PureOperatorError>
pub fn checked_mul( &self, other: ExactRational, ) -> Result<ExactRational, PureOperatorError>
Exact product within the coefficient work budget.
pub fn checked_div(
&self,
other: ExactRational,
) -> Result<ExactRational, PureOperatorError>
pub fn checked_div( &self, other: ExactRational, ) -> Result<ExactRational, PureOperatorError>
Exact quotient within the coefficient work budget; rejects division by zero.
Trait Implementations§
§impl Clone for ExactRational
impl Clone for ExactRational
§impl Debug for ExactRational
impl Debug for ExactRational
§impl<'de> Deserialize<'de> for ExactRational
impl<'de> Deserialize<'de> for ExactRational
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ExactRational, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ExactRational, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Hash for ExactRational
impl Hash for ExactRational
§fn hash<__H>(&self, state: &mut __H)where
__H: Hasher,
fn hash<__H>(&self, state: &mut __H)where
__H: Hasher,
§impl Ord for ExactRational
impl Ord for ExactRational
§fn cmp(&self, other: &ExactRational) -> Ordering
fn cmp(&self, other: &ExactRational) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
§impl PartialEq for ExactRational
impl PartialEq for ExactRational
§fn eq(&self, other: &ExactRational) -> bool
fn eq(&self, other: &ExactRational) -> bool
self and other values to be equal, and is used by ==.§impl PartialOrd for ExactRational
impl PartialOrd for ExactRational
§fn partial_cmp(&self, other: &ExactRational) -> Option<Ordering>
fn partial_cmp(&self, other: &ExactRational) -> Option<Ordering>
1.0.0 (const: unstable) · Source§fn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
1.0.0 (const: unstable) · Source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
1.0.0 (const: unstable) · Source§fn gt(&self, other: &Rhs) -> bool
fn gt(&self, other: &Rhs) -> bool
§impl Serialize for ExactRational
impl Serialize for ExactRational
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl TryFrom<CanonicalRational> for ExactRational
impl TryFrom<CanonicalRational> for ExactRational
§type Error = PureOperatorError
type Error = PureOperatorError
§fn try_from(
value: CanonicalRational,
) -> Result<ExactRational, <ExactRational as TryFrom<CanonicalRational>>::Error>
fn try_from( value: CanonicalRational, ) -> Result<ExactRational, <ExactRational as TryFrom<CanonicalRational>>::Error>
§impl TryFrom<Ratio<BigInt>> for ExactRational
impl TryFrom<Ratio<BigInt>> for ExactRational
§fn try_from(
value: Ratio<BigInt>,
) -> Result<ExactRational, <ExactRational as TryFrom<Ratio<BigInt>>>::Error>
fn try_from( value: Ratio<BigInt>, ) -> Result<ExactRational, <ExactRational as TryFrom<Ratio<BigInt>>>::Error>
Admit an existing exact ratio through the same canonical work bound.
§type Error = PureOperatorError
type Error = PureOperatorError
impl Eq for ExactRational
impl StructuralPartialEq for ExactRational
Auto Trait Implementations§
impl Freeze for ExactRational
impl RefUnwindSafe for ExactRational
impl Send for ExactRational
impl Sync for ExactRational
impl Unpin for ExactRational
impl UnsafeUnpin for ExactRational
impl UnwindSafe for ExactRational
Blanket Implementations§
Source§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Source§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Qwhere
Q: Ord + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Comparable<K> for Qwhere
Q: Ord + ?Sized,
K: Borrow<Q> + ?Sized,
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§fn approx(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
§fn into_as<Dst>(self) -> Dstwhere
Self: Sized + Into<Dst>,
fn into_as<Dst>(self) -> Dstwhere
Self: Sized + Into<Dst>,
§fn try_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + TryInto<Dst>,
fn try_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + TryInto<Dst>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> From<T> for T
impl<T> From<T> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
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>
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>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Same for T
impl<T> Same for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.