Skip to main content

DecimalArithmetic

Trait DecimalArithmetic 

Source
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§

Source

const SCALE: u32

The decimal scale of this type.

Source

const MAX_SCALE: u32

The maximum legal SCALE for this width.

Source

const ZERO: Self

The additive identity.

Source

const ONE: Self

The multiplicative identity.

Source

const MAX: Self

The largest representable value.

Source

const MIN: Self

The smallest representable value.

Required Associated Types§

Source

type Storage: Copy + PartialEq + Eq

Underlying integer storage type (e.g. i128 for D38<SCALE>).

Required Methods§

Source

fn multiplier() -> Self::Storage

Returns 10^SCALE.

Source

fn abs(self) -> Self

Source

fn signum(self) -> Self

Source

fn is_positive(self) -> bool

Source

fn is_negative(self) -> bool

Source

fn is_nan(self) -> bool

Source

fn is_infinite(self) -> bool

Source

fn is_finite(self) -> bool

Source

fn div_euclid(self, rhs: Self) -> Self

Source

fn rem_euclid(self, rhs: Self) -> Self

Source

fn div_floor(self, rhs: Self) -> Self

Source

fn div_ceil(self, rhs: Self) -> Self

Source

fn abs_diff(self, rhs: Self) -> Self

Source

fn midpoint(self, rhs: Self) -> Self

Source

fn mul_add(self, a: Self, b: Self) -> Self

Source

fn pow(self, exp: u32) -> Self

Source

fn powi(self, exp: i32) -> Self

Source

fn checked_pow(self, exp: u32) -> Option<Self>

Source

fn wrapping_pow(self, exp: u32) -> Self

Source

fn saturating_pow(self, exp: u32) -> Self

Source

fn overflowing_pow(self, exp: u32) -> (Self, bool)

Source

fn checked_add(self, rhs: Self) -> Option<Self>

Source

fn checked_sub(self, rhs: Self) -> Option<Self>

Source

fn checked_mul(self, rhs: Self) -> Option<Self>

Source

fn checked_div(self, rhs: Self) -> Option<Self>

Source

fn checked_neg(self) -> Option<Self>

Source

fn checked_rem(self, rhs: Self) -> Option<Self>

Source

fn wrapping_add(self, rhs: Self) -> Self

Source

fn wrapping_sub(self, rhs: Self) -> Self

Source

fn wrapping_mul(self, rhs: Self) -> Self

Source

fn wrapping_div(self, rhs: Self) -> Self

Source

fn wrapping_neg(self) -> Self

Source

fn wrapping_rem(self, rhs: Self) -> Self

Source

fn saturating_add(self, rhs: Self) -> Self

Source

fn saturating_sub(self, rhs: Self) -> Self

Source

fn saturating_mul(self, rhs: Self) -> Self

Source

fn saturating_div(self, rhs: Self) -> Self

Source

fn saturating_neg(self) -> Self

Source

fn overflowing_add(self, rhs: Self) -> (Self, bool)

Source

fn overflowing_sub(self, rhs: Self) -> (Self, bool)

Source

fn overflowing_mul(self, rhs: Self) -> (Self, bool)

Source

fn overflowing_div(self, rhs: Self) -> (Self, bool)

Source

fn overflowing_neg(self) -> (Self, bool)

Source

fn overflowing_rem(self, rhs: Self) -> (Self, bool)

Provided Methods§

Source

fn is_zero(self) -> bool

Source

fn is_one(self) -> bool

Source

fn is_normal(self) -> bool

Source

fn sum<I>(iter: I) -> Self
where I: IntoIterator<Item = Self>,

Source

fn product<I>(iter: I) -> Self
where 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.

Implementors§

Source§

impl<const SCALE: u32> DecimalArithmetic for D9<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 8

Source§

const ZERO: Self = D9<SCALE>::ZERO

Source§

const ONE: Self = D9<SCALE>::ONE

Source§

const MAX: Self = D9<SCALE>::MAX

Source§

const MIN: Self = D9<SCALE>::MIN

Source§

type Storage = i32

Source§

impl<const SCALE: u32> DecimalArithmetic for D18<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 17

Source§

const ZERO: Self = D18<SCALE>::ZERO

Source§

const ONE: Self = D18<SCALE>::ONE

Source§

const MAX: Self = D18<SCALE>::MAX

Source§

const MIN: Self = D18<SCALE>::MIN

Source§

type Storage = i64

Source§

impl<const SCALE: u32> DecimalArithmetic for D38<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 37

Source§

const ZERO: Self = D38<SCALE>::ZERO

Source§

const ONE: Self = D38<SCALE>::ONE

Source§

const MAX: Self = D38<SCALE>::MAX

Source§

const MIN: Self = D38<SCALE>::MIN

Source§

type Storage = i128

Source§

impl<const SCALE: u32> DecimalArithmetic for D57<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 56

Source§

const ZERO: Self = D57<SCALE>::ZERO

Source§

const ONE: Self = D57<SCALE>::ONE

Source§

const MAX: Self = D57<SCALE>::MAX

Source§

const MIN: Self = D57<SCALE>::MIN

Source§

type Storage = Int192

Source§

impl<const SCALE: u32> DecimalArithmetic for D76<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 75

Source§

const ZERO: Self = D76<SCALE>::ZERO

Source§

const ONE: Self = D76<SCALE>::ONE

Source§

const MAX: Self = D76<SCALE>::MAX

Source§

const MIN: Self = D76<SCALE>::MIN

Source§

type Storage = Int256

Source§

impl<const SCALE: u32> DecimalArithmetic for D115<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 114

Source§

const ZERO: Self = D115<SCALE>::ZERO

Source§

const ONE: Self = D115<SCALE>::ONE

Source§

const MAX: Self = D115<SCALE>::MAX

Source§

const MIN: Self = D115<SCALE>::MIN

Source§

type Storage = Int384

Source§

impl<const SCALE: u32> DecimalArithmetic for D153<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 152

Source§

const ZERO: Self = D153<SCALE>::ZERO

Source§

const ONE: Self = D153<SCALE>::ONE

Source§

const MAX: Self = D153<SCALE>::MAX

Source§

const MIN: Self = D153<SCALE>::MIN

Source§

type Storage = Int512

Source§

impl<const SCALE: u32> DecimalArithmetic for D230<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 229

Source§

const ZERO: Self = D230<SCALE>::ZERO

Source§

const ONE: Self = D230<SCALE>::ONE

Source§

const MAX: Self = D230<SCALE>::MAX

Source§

const MIN: Self = D230<SCALE>::MIN

Source§

type Storage = Int768

Source§

impl<const SCALE: u32> DecimalArithmetic for D307<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 306

Source§

const ZERO: Self = D307<SCALE>::ZERO

Source§

const ONE: Self = D307<SCALE>::ONE

Source§

const MAX: Self = D307<SCALE>::MAX

Source§

const MIN: Self = D307<SCALE>::MIN

Source§

type Storage = Int1024

Source§

impl<const SCALE: u32> DecimalArithmetic for D462<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 461

Source§

const ZERO: Self = D462<SCALE>::ZERO

Source§

const ONE: Self = D462<SCALE>::ONE

Source§

const MAX: Self = D462<SCALE>::MAX

Source§

const MIN: Self = D462<SCALE>::MIN

Source§

type Storage = Int1536

Source§

impl<const SCALE: u32> DecimalArithmetic for D616<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 615

Source§

const ZERO: Self = D616<SCALE>::ZERO

Source§

const ONE: Self = D616<SCALE>::ONE

Source§

const MAX: Self = D616<SCALE>::MAX

Source§

const MIN: Self = D616<SCALE>::MIN

Source§

type Storage = Int2048

Source§

impl<const SCALE: u32> DecimalArithmetic for D924<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 923

Source§

const ZERO: Self = D924<SCALE>::ZERO

Source§

const ONE: Self = D924<SCALE>::ONE

Source§

const MAX: Self = D924<SCALE>::MAX

Source§

const MIN: Self = D924<SCALE>::MIN

Source§

type Storage = Int3072

Source§

impl<const SCALE: u32> DecimalArithmetic for D1232<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 1231

Source§

const ZERO: Self = D1232<SCALE>::ZERO

Source§

const ONE: Self = D1232<SCALE>::ONE

Source§

const MAX: Self = D1232<SCALE>::MAX

Source§

const MIN: Self = D1232<SCALE>::MIN

Source§

type Storage = Int4096