pub enum Arithmetic {
Int(i128),
IEEE754(f64),
Decimal(BigInt, i128),
Float(BigInt, i128),
}Expand description
Representation of numeric values for the purpose of computation.
The rules for binary operations are:
- first bring both operands to the more precise of the two representations
i128andf64use Rust native semantics;i128overflow spills into Decimal- +/-/% just act on the mantissa
-
- uses m1*m2 * base^(e1+e2)
- / keeps the precision of the divident and truncates
- ^ extends precision of exponent to at least 0 and uses m1^m2 * base^(e1*m2) (in case of negative e2 followed by base^(-e2)-th root)
This implies the need for operators that convert to a specific precision.
Variants§
Auto Trait Implementations§
impl Freeze for Arithmetic
impl RefUnwindSafe for Arithmetic
impl Send for Arithmetic
impl Sync for Arithmetic
impl Unpin for Arithmetic
impl UnwindSafe for Arithmetic
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
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