pub trait DecimalArithmetic:
Copy
+ PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Default
+ Debug
+ Display
+ Hash
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ Div<Output = Self>
+ Rem<Output = Self>
+ Neg<Output = Self>
+ AddAssign
+ SubAssign
+ MulAssign
+ DivAssign
+ RemAssign
+ BitAnd<Output = Self>
+ BitOr<Output = Self>
+ BitXor<Output = Self>
+ Not<Output = Self>
+ Shl<u32, Output = Self>
+ Shr<u32, Output = Self> {
type Storage: Copy + PartialEq + Eq;
const SCALE: u32;
const MAX_SCALE: u32;
const ZERO: Self;
const ONE: Self;
const MAX: Self;
const MIN: Self;
Show 49 methods
// Required methods
fn multiplier() -> Self::Storage;
fn abs(self) -> Self;
fn signum(self) -> Self;
fn is_positive(self) -> bool;
fn is_negative(self) -> bool;
fn is_nan(self) -> bool;
fn is_infinite(self) -> bool;
fn is_finite(self) -> bool;
fn div_euclid(self, rhs: Self) -> Self;
fn rem_euclid(self, rhs: Self) -> Self;
fn div_floor(self, rhs: Self) -> Self;
fn div_ceil(self, rhs: Self) -> Self;
fn abs_diff(self, rhs: Self) -> Self;
fn midpoint(self, rhs: Self) -> Self;
fn mul_add(self, a: Self, b: Self) -> Self;
fn pow(self, exp: u32) -> Self;
fn powi(self, exp: i32) -> Self;
fn checked_pow(self, exp: u32) -> Option<Self>;
fn wrapping_pow(self, exp: u32) -> Self;
fn saturating_pow(self, exp: u32) -> Self;
fn overflowing_pow(self, exp: u32) -> (Self, bool);
fn checked_add(self, rhs: Self) -> Option<Self>;
fn checked_sub(self, rhs: Self) -> Option<Self>;
fn checked_mul(self, rhs: Self) -> Option<Self>;
fn checked_div(self, rhs: Self) -> Option<Self>;
fn checked_neg(self) -> Option<Self>;
fn checked_rem(self, rhs: Self) -> Option<Self>;
fn wrapping_add(self, rhs: Self) -> Self;
fn wrapping_sub(self, rhs: Self) -> Self;
fn wrapping_mul(self, rhs: Self) -> Self;
fn wrapping_div(self, rhs: Self) -> Self;
fn wrapping_neg(self) -> Self;
fn wrapping_rem(self, rhs: Self) -> Self;
fn saturating_add(self, rhs: Self) -> Self;
fn saturating_sub(self, rhs: Self) -> Self;
fn saturating_mul(self, rhs: Self) -> Self;
fn saturating_div(self, rhs: Self) -> Self;
fn saturating_neg(self) -> Self;
fn overflowing_add(self, rhs: Self) -> (Self, bool);
fn overflowing_sub(self, rhs: Self) -> (Self, bool);
fn overflowing_mul(self, rhs: Self) -> (Self, bool);
fn overflowing_div(self, rhs: Self) -> (Self, bool);
fn overflowing_neg(self) -> (Self, bool);
fn overflowing_rem(self, rhs: Self) -> (Self, bool);
// Provided methods
fn is_zero(self) -> bool { ... }
fn is_one(self) -> bool { ... }
fn is_normal(self) -> bool { ... }
fn sum<I>(iter: I) -> Self
where I: IntoIterator<Item = Self> { ... }
fn product<I>(iter: I) -> Self
where I: IntoIterator<Item = Self> { ... }
}Expand description
Arithmetic surface shared by every decimal width: type info,
constants, operators, sign methods, integer-shape predicates,
integer-style division helpers, integer-exponent powers, the
checked / wrapping / saturating / overflowing variants of every
operator, and reductions (sum / product).
See module-level docs for usage; see crate::DecimalConvert
for the conversion surface and crate::Decimal for the marker
supertrait that combines all four halves.
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn multiplier() -> Self::Storage
fn multiplier() -> Self::Storage
Returns 10^SCALE.
fn abs(self) -> Self
fn signum(self) -> Self
fn is_positive(self) -> bool
fn is_negative(self) -> bool
fn is_nan(self) -> bool
fn is_infinite(self) -> bool
fn is_finite(self) -> bool
fn div_euclid(self, rhs: Self) -> Self
fn rem_euclid(self, rhs: Self) -> Self
fn div_floor(self, rhs: Self) -> Self
fn div_ceil(self, rhs: Self) -> Self
fn abs_diff(self, rhs: Self) -> Self
fn midpoint(self, rhs: Self) -> Self
fn mul_add(self, a: Self, b: Self) -> Self
fn pow(self, exp: u32) -> Self
fn powi(self, exp: i32) -> Self
fn checked_pow(self, exp: u32) -> Option<Self>
fn wrapping_pow(self, exp: u32) -> Self
fn saturating_pow(self, exp: u32) -> Self
fn overflowing_pow(self, exp: u32) -> (Self, bool)
fn checked_add(self, rhs: Self) -> Option<Self>
fn checked_sub(self, rhs: Self) -> Option<Self>
fn checked_mul(self, rhs: Self) -> Option<Self>
fn checked_div(self, rhs: Self) -> Option<Self>
fn checked_neg(self) -> Option<Self>
fn checked_rem(self, rhs: Self) -> Option<Self>
fn wrapping_add(self, rhs: Self) -> Self
fn wrapping_sub(self, rhs: Self) -> Self
fn wrapping_mul(self, rhs: Self) -> Self
fn wrapping_div(self, rhs: Self) -> Self
fn wrapping_neg(self) -> Self
fn wrapping_rem(self, rhs: Self) -> Self
fn saturating_add(self, rhs: Self) -> Self
fn saturating_sub(self, rhs: Self) -> Self
fn saturating_mul(self, rhs: Self) -> Self
fn saturating_div(self, rhs: Self) -> Self
fn saturating_neg(self) -> Self
fn overflowing_add(self, rhs: Self) -> (Self, bool)
fn overflowing_sub(self, rhs: Self) -> (Self, bool)
fn overflowing_mul(self, rhs: Self) -> (Self, bool)
fn overflowing_div(self, rhs: Self) -> (Self, bool)
fn overflowing_neg(self) -> (Self, bool)
fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Provided Methods§
fn is_zero(self) -> bool
fn is_one(self) -> bool
fn is_normal(self) -> bool
fn sum<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Self>,
fn product<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.