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 = 9

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 = 18

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 = 38

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 D56<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 57

Source§

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

Source§

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

Source§

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

Source§

const MIN: Self = D56<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 = 76

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 D114<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 115

Source§

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

Source§

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

Source§

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

Source§

const MIN: Self = D114<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 = 153

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 = 230

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 = 307

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 D461<SCALE>

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 462

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Storage = Int1536

Source§

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

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 616

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Storage = Int2048

Source§

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

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 924

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Storage = Int3072

Source§

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

Source§

const SCALE: u32 = SCALE

Source§

const MAX_SCALE: u32 = 1232

Source§

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

Source§

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

Source§

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

Source§

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

Source§

type Storage = Int4096