pub type D38<const SCALE: u32> = D<Int<2>, SCALE>;Expand description
Scaled fixed-point decimal with 128-bit storage. A type alias
of the unified crate::D generic decimal type: D38<S> is
D<i128, S>. Both spellings are interchangeable.
SCALE is the base-10 exponent. A logical value v is stored as
v * 10^SCALE in the underlying i128. For example, with SCALE = 12
the number 1.5 is stored as i128(1_500_000_000_000).
The #[repr(transparent)] layout over i128 is preserved through
the alias because the underlying crate::D is itself
#[repr(transparent)] over its storage parameter.
§Precision
N/A: type definition, no arithmetic performed.
§Determinism
All arithmetic is integer arithmetic on i128. The same inputs produce
the same bit-pattern on every platform.
§Equality and ordering
Hash, Eq, and Ord are derived from i128. Two D38<S> values
are equal if and only if their underlying i128 fields are bit-equal.
This works because the scale is fixed at compile time – each logical
value has exactly one representation.
§Const-generic scale
The const generic allows scale variants (D38<9>, D38<6>, etc.)
as trivial type aliases without duplicating any method implementations.
Mixed-scale arithmetic is deliberately not provided; callers convert
explicitly.
Aliased Type§
#[repr(transparent)]pub struct D38<const SCALE: u32>(pub Int<2>);Tuple Fields§
§0: Int<2>Implementations§
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub const SCALE: u32 = SCALE
pub const SCALE: u32 = SCALE
The decimal scale of this type, equal to the SCALE
const-generic parameter. One LSB of storage represents
10^-SCALE. Use in type-level / const contexts; prefer
Self::scale when an instance is in hand.
Sourcepub const ZERO: Self
pub const ZERO: Self
The additive identity. Stored as zero bits.
§Precision
N/A: constant value, no arithmetic performed.
Sourcepub const ONE: Self
pub const ONE: Self
The multiplicative identity. Stored as 10^SCALE bits.
§Precision
N/A: constant value, no arithmetic performed.
Sourcepub const MAX: Self
pub const MAX: Self
The largest representable value: the storage type’s MAX.
Default arithmetic that overflows this bound panics in both
debug and release (the explicit wrapping_* / checked_* /
saturating_* variants apply the other policies).
Sourcepub const MIN: Self
pub const MIN: Self
The smallest representable value: the storage type’s MIN.
Mirror of Self::MAX. Note that -MIN panics in both
debug and release because two’s-complement MIN has no
positive counterpart.
Sourcepub const EPSILON: Self
pub const EPSILON: Self
Smallest representable positive value: 1 LSB = 10^-SCALE.
Provided as an analogue to f64::EPSILON for generic
numeric code that wants the smallest non-zero positive
step. Differs from the f64 definition (“difference
between 1.0 and the next-larger f64”): on a
fixed-scale decimal the LSB is uniform across the
representable range. There are no subnormals.
Useful when you need a “smallest positive step” value
without writing Self::from_bits(<storage>::from_u128(1))
out longhand — particularly with wide-tier storage
where the literal 1 isn’t directly the wide-int type.
Sourcepub const MIN_POSITIVE: Self
pub const MIN_POSITIVE: Self
Smallest positive value (equal to Self::EPSILON).
Provided as an analogue to f64::MIN_POSITIVE for
generic numeric code. Unlike f64, fixed-scale decimal
types have no subnormals, so MIN_POSITIVE and
EPSILON are the same value.
Sourcepub const fn from_bits(raw: Int<2>) -> Self
pub const fn from_bits(raw: Int<2>) -> Self
Constructs from a raw storage bit pattern.
The integer is interpreted directly as the internal storage:
raw represents the logical value raw * 10^(-SCALE). This
is the inverse of Self::to_bits.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
Sourcepub const fn to_bits(self) -> Int<2>
pub const fn to_bits(self) -> Int<2>
Returns the raw storage value.
The returned integer encodes the logical value
self * 10^SCALE. This is the inverse of Self::from_bits.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
Sourcepub const fn multiplier() -> Int<2>
pub const fn multiplier() -> Int<2>
Returns 10^SCALE, the factor that converts a logical
integer value to its storage representation. Equals the
bit pattern of Self::ONE.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Overflow
10^SCALE overflows the storage type at SCALE > MAX_SCALE.
Calling with an overflowing scale panics at compile time
when the const item is evaluated.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn unsigned_shr(self, n: u32) -> Self
pub fn unsigned_shr(self, n: u32) -> Self
Logical (zero-fill) right shift of the raw storage by n
bits. Unlike the arithmetic Shr operator, the vacated
high bits are always zero regardless of sign.
Sourcepub fn rotate_left(self, n: u32) -> Self
pub fn rotate_left(self, n: u32) -> Self
Rotate the raw storage left by n bits.
Sourcepub fn rotate_right(self, n: u32) -> Self
pub fn rotate_right(self, n: u32) -> Self
Rotate the raw storage right by n bits.
Sourcepub fn leading_zeros(self) -> u32
pub fn leading_zeros(self) -> u32
Number of leading zero bits in the raw storage.
Sourcepub fn trailing_zeros(self) -> u32
pub fn trailing_zeros(self) -> u32
Number of trailing zero bits in the raw storage.
Sourcepub fn count_ones(self) -> u32
pub fn count_ones(self) -> u32
Population count of the raw storage.
Sourcepub fn count_zeros(self) -> u32
pub fn count_zeros(self) -> u32
Number of zero bits in the raw storage.
Sourcepub fn is_power_of_two(self) -> bool
pub fn is_power_of_two(self) -> bool
true if the raw storage, viewed as unsigned, is a power
of two.
Sourcepub fn next_power_of_two(self) -> Self
pub fn next_power_of_two(self) -> Self
Smallest power of two >= the raw storage viewed as unsigned. Panics in debug builds on overflow.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn div_euclid(self, rhs: Self) -> Self
pub fn div_euclid(self, rhs: Self) -> Self
Euclidean division: the quotient as an integer multiple of
ONE, chosen so the remainder is non-negative. Panics on
rhs == ZERO.
Sourcepub fn rem_euclid(self, rhs: Self) -> Self
pub fn rem_euclid(self, rhs: Self) -> Self
Euclidean remainder: self - rhs * self.div_euclid(rhs),
always non-negative when rhs != ZERO. Both operands
share the scale, so no rescaling is needed. Panics on
rhs == ZERO.
Sourcepub fn abs_diff(self, rhs: Self) -> Self
pub fn abs_diff(self, rhs: Self) -> Self
Absolute difference |self - rhs|. Computed as
max - min so the subtraction is always non-negative.
Sourcepub fn midpoint(self, rhs: Self) -> Self
pub fn midpoint(self, rhs: Self) -> Self
Midpoint of self and rhs without intermediate
overflow, rounding toward negative infinity. Uses the
branch-free (a & b) + ((a ^ b) >> 1) identity, which is
overflow-free and storage-agnostic.
Sourcepub const fn is_infinite(self) -> bool
pub const fn is_infinite(self) -> bool
Always false — a fixed-point decimal has no infinity.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn from_f64(value: f64) -> Self
pub fn from_f64(value: f64) -> Self
Constructs from an f64 using the crate default rounding
mode. NaN -> ZERO, +Infinity -> MAX, -Infinity -> MIN,
out-of-range -> saturate by sign.
Sourcepub fn from_f64_with(value: f64, mode: RoundingMode) -> Self
pub fn from_f64_with(value: f64, mode: RoundingMode) -> Self
Constructs from an f64 using the supplied rounding
mode. Saturation policy as in Self::from_f64.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn to_int(self) -> i64
pub fn to_int(self) -> i64
Converts to i64 using the crate default rounding mode.
Saturates to i64::MAX / i64::MIN when the rounded
integer part falls outside i64’s range.
Sourcepub fn to_int_with(self, mode: RoundingMode) -> i64
pub fn to_int_with(self, mode: RoundingMode) -> i64
Converts to i64 using the supplied rounding mode for the
fractional discard step. Saturates to i64::MAX /
i64::MIN when the rounded integer is out of i64 range.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub const fn abs(self) -> Self
pub const fn abs(self) -> Self
Returns the absolute value of self.
abs(MIN) overflows: |MIN| has no positive counterpart
in two’s-complement. Because this is a const fn, it
takes the stricter const overflow contract — it
always panics on overflow (an unconditional
checked_neg(…).expect(…)), so in a const context the
overflowing case is a compile-time evaluation error,
profile-independent, matching std’s const integer
arithmetic. At runtime it panics in both debug and
release.
Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns the sign of self encoded as a scaled Self:
-ONE, ZERO, or +ONE.
Sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true if self is strictly greater than zero.
Sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true if self is strictly less than zero.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn checked_add(self, rhs: Self) -> Option<Self>
Checked addition. Some(self + rhs), or None if the
sum would overflow Self.
Sourcepub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn wrapping_add(self, rhs: Self) -> Self
Wrapping addition. self + rhs modulo the storage
type’s MAX − MIN range.
Sourcepub const fn saturating_add(self, rhs: Self) -> Self
pub const fn saturating_add(self, rhs: Self) -> Self
Sourcepub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
Overflowing addition. Returns (self.wrapping_add(rhs), overflowed).
Sourcepub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
Checked subtraction. Some(self - rhs), or None if
the difference would overflow Self.
Sourcepub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn wrapping_sub(self, rhs: Self) -> Self
Wrapping subtraction.
Sourcepub const fn saturating_sub(self, rhs: Self) -> Self
pub const fn saturating_sub(self, rhs: Self) -> Self
Sourcepub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
Overflowing subtraction. Returns
(self.wrapping_sub(rhs), overflowed).
Sourcepub const fn checked_neg(self) -> Option<Self>
pub const fn checked_neg(self) -> Option<Self>
Checked negation. Some(-self), or None when
self == Self::MIN (whose negation is unrepresentable
in two’s-complement).
Sourcepub const fn wrapping_neg(self) -> Self
pub const fn wrapping_neg(self) -> Self
Wrapping negation. Self::MIN.wrapping_neg() == Self::MIN
(same as i128::wrapping_neg).
Sourcepub const fn saturating_neg(self) -> Self
pub const fn saturating_neg(self) -> Self
Saturating negation. Self::MIN.saturating_neg() == Self::MAX.
Sourcepub const fn overflowing_neg(self) -> (Self, bool)
pub const fn overflowing_neg(self) -> (Self, bool)
Overflowing negation. Returns
(self.wrapping_neg(), overflowed); overflowed is
true only when self == Self::MIN.
Sourcepub const fn checked_rem(self, rhs: Self) -> Option<Self>
pub const fn checked_rem(self, rhs: Self) -> Option<Self>
Checked remainder. Some(self % rhs), or None if
rhs == 0 or the operation would overflow (the
pathological case Self::MIN % -ONE).
Sourcepub const fn wrapping_rem(self, rhs: Self) -> Self
pub const fn wrapping_rem(self, rhs: Self) -> Self
Wrapping remainder. Panics on divide-by-zero
(matches i128::wrapping_rem).
Sourcepub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool)
Overflowing remainder. Returns
(self.wrapping_rem(rhs), overflowed); overflowed
is true only at the Self::MIN % -ONE boundary.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn checked_mul(self, rhs: Self) -> Option<Self>
pub fn checked_mul(self, rhs: Self) -> Option<Self>
Checked multiplication. Computes self * rhs rounded
toward zero, returning None if the result doesn’t fit
in Self. The intermediate product is computed in
$Wider so widening overflow is detected before the
final narrowing.
Sourcepub fn wrapping_mul(self, rhs: Self) -> Self
pub fn wrapping_mul(self, rhs: Self) -> Self
Wrapping multiplication. Computes self * rhs modulo
the storage type’s MAX − MIN range. The intermediate
product still widens to $Wider; only the narrowing
step wraps.
Sourcepub fn saturating_mul(self, rhs: Self) -> Self
pub fn saturating_mul(self, rhs: Self) -> Self
Sourcepub fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Overflowing multiplication. Returns the wrapped result
together with a boolean flag — true if the
mathematical product was out of range.
Sourcepub fn checked_div(self, rhs: Self) -> Option<Self>
pub fn checked_div(self, rhs: Self) -> Option<Self>
Checked division. Returns None if rhs is zero or
the result would overflow Self. Rounds to nearest
using the crate-default RoundingMode,
identical to the / operator. The numerator is pre-multiplied by
10^SCALE in $Wider so the intermediate carries the
scale-up step exactly before rounding.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs rounded to
nearest using the crate-default RoundingMode
(like the / operator), with the scale-up step done modulo
$Wider’s range and the final narrowing wrapping.
Panics on divide-by-zero (matches i128::wrapping_div).
Sourcepub fn saturating_div(self, rhs: Self) -> Self
pub fn saturating_div(self, rhs: Self) -> Self
Sourcepub fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub fn overflowing_div(self, rhs: Self) -> (Self, bool)
Overflowing division. Returns the wrapped result
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn mul_with(self, rhs: Self, mode: RoundingMode) -> Self
pub fn mul_with(self, rhs: Self, mode: RoundingMode) -> Self
Multiply two values of the same scale, rounding the
scale-narrowing step according to mode. Result is
within 0.5 ULP for the half-* family and bounded by the
directed-rounding rule otherwise.
For SCALE ≤ 38 the divide-by-10^SCALE step routes
through the Möller-Granlund magic-divide kernel shared
with D38 — avoiding the generic schoolbook divide for
the common case. Larger scales fall through to the
slower n / (10^SCALE) path.
Routes through the generic crate::policy::mul::dispatch
matcher; N is inferred from self.0: Int<N>.
Sourcepub fn div_with(self, rhs: Self, mode: RoundingMode) -> Self
pub fn div_with(self, rhs: Self, mode: RoundingMode) -> Self
Divide two values of the same scale, rounding the
scale-narrowing step according to mode. Within 0.5 ULP
for the half-* family.
The divisor here is the runtime operand rhs.0, not
10^SCALE, so the MG magic-divide doesn’t apply; the
final step uses the wide integer’s schoolbook
limbs_divmod (which has its own hardware fast paths
for sub-word divisors). Scaling the numerator uses the
type’s multiplier() const (already evaluated at the
$Storage width) widened to $Wider, avoiding the
per-call pow(SCALE) on the wider type.
Routes through the generic crate::policy::div::dispatch
matcher; N is inferred from self.0: Int<N>.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn from_num<T: ToPrimitive>(value: T) -> Self
pub fn from_num<T: ToPrimitive>(value: T) -> Self
Saturating T → Self via num_traits::NumCast.
Out-of-range / ±Infinity saturate to MAX / MIN;
NaN maps to Self::ZERO. See the module-level docs.
Sourcepub fn to_num<T: NumCast + Bounded>(self) -> T
pub fn to_num<T: NumCast + Bounded>(self) -> T
Saturating Self → T via num_traits::NumCast.
Out-of-range targets saturate to T::max_value() /
T::min_value(). Never panics.
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn mul_of<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
) -> Self
pub fn mul_of<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, ) -> Self
Constructs Self as a × b, where a and b may have
any width ≤ Self’s and any SCALE. Both operands are
widened to Self’s storage, rescaled to Self’s
SCALE (UP-rescale is exact; DOWN uses the crate’s
default rounding mode), then multiplied. Panics on overflow
in both debug and release, matching the same-width
same-SCALE Mul operator.
See Self::mul_of_with for an explicit-rounding form.
Sourcepub fn mul_of_with<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
mode: RoundingMode,
) -> Self
pub fn mul_of_with<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, mode: RoundingMode, ) -> Self
Like Self::mul_of but with an explicit rounding mode
for any DOWN-rescale of a / b to Self’s SCALE.
Sourcepub fn add_of<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
) -> Self
pub fn add_of<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, ) -> Self
Constructs Self as a + b (cross-width / cross-SCALE).
See Self::mul_of for semantics.
Sourcepub fn add_of_with<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
mode: RoundingMode,
) -> Self
pub fn add_of_with<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, mode: RoundingMode, ) -> Self
Like Self::add_of but with explicit rounding for the
input rescale step.
Sourcepub fn sub_of<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
) -> Self
pub fn sub_of<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, ) -> Self
Constructs Self as a - b (cross-width / cross-SCALE).
Sourcepub fn sub_of_with<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
mode: RoundingMode,
) -> Self
pub fn sub_of_with<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, mode: RoundingMode, ) -> Self
Like Self::sub_of but with explicit rounding for the
input rescale step.
Sourcepub fn div_of<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
) -> Self
pub fn div_of<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, ) -> Self
Constructs Self as a / b (cross-width / cross-SCALE).
Sourcepub fn div_of_with<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
mode: RoundingMode,
) -> Self
pub fn div_of_with<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, mode: RoundingMode, ) -> Self
Like Self::div_of but with explicit rounding for both
the input rescale step and the truncating divide.
Sourcepub fn rem_of<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
) -> Self
pub fn rem_of<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, ) -> Self
Constructs Self as a % b (cross-width / cross-SCALE).
Sourcepub fn rem_of_with<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
mode: RoundingMode,
) -> Self
pub fn rem_of_with<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, mode: RoundingMode, ) -> Self
Like Self::rem_of but with explicit rounding for the
input rescale step.
Sourcepub fn max_of<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
) -> Self
pub fn max_of<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, ) -> Self
Returns the larger of a and b as Self. Comparison
is done at the wider operand’s SCALE (lossless via
UP-rescale on both sides); the winner is then rescaled
to Self’s SCALE using the crate’s default rounding
mode.
Sourcepub fn max_of_with<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
mode: RoundingMode,
) -> Self
pub fn max_of_with<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, mode: RoundingMode, ) -> Self
Like Self::max_of but with an explicit rounding mode
for the final rescale to Self’s SCALE.
Sourcepub fn min_of<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
) -> Self
pub fn min_of<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, ) -> Self
Returns the smaller of a and b as Self. See
Self::max_of for the comparison + rescale semantics.
Sourcepub fn min_of_with<W1, W2, const S1: u32, const S2: u32>(
a: D<W1, S1>,
b: D<W2, S2>,
mode: RoundingMode,
) -> Self
pub fn min_of_with<W1, W2, const S1: u32, const S2: u32>( a: D<W1, S1>, b: D<W2, S2>, mode: RoundingMode, ) -> Self
Like Self::min_of but with an explicit rounding mode
for the final rescale to Self’s SCALE.
Sourcepub fn clamp_of<W1, W2, W3, const SV: u32, const SLO: u32, const SHI: u32>(
value: D<W1, SV>,
lo: D<W2, SLO>,
hi: D<W3, SHI>,
) -> Self
pub fn clamp_of<W1, W2, W3, const SV: u32, const SLO: u32, const SHI: u32>( value: D<W1, SV>, lo: D<W2, SLO>, hi: D<W3, SHI>, ) -> Self
Clamps value to the inclusive range [lo, hi],
returning the result as Self. All three operands may
have any width ≤ Self’s and any SCALE. The comparison
is exact (each pairwise compare runs at the higher of
the two scales, lossless); the result is then rescaled
to Self’s SCALE using the crate’s default rounding
mode.
Panics if lo > hi (matching core::cmp::Ord::clamp).
Sourcepub fn clamp_of_with<W1, W2, W3, const SV: u32, const SLO: u32, const SHI: u32>(
value: D<W1, SV>,
lo: D<W2, SLO>,
hi: D<W3, SHI>,
mode: RoundingMode,
) -> Self
pub fn clamp_of_with<W1, W2, W3, const SV: u32, const SLO: u32, const SHI: u32>( value: D<W1, SV>, lo: D<W2, SLO>, hi: D<W3, SHI>, mode: RoundingMode, ) -> Self
Like Self::clamp_of but with an explicit rounding
mode for the rescale to Self’s SCALE.
Sourcepub fn convert_from<W1, const S1: u32>(
src: D<W1, S1>,
) -> Result<Self, ConvertError>where
W1: BigInt,
pub fn convert_from<W1, const S1: u32>(
src: D<W1, S1>,
) -> Result<Self, ConvertError>where
W1: BigInt,
Converts a source decimal of any storage width W1 and
any SCALE S1 to Self (the target tier at the target
SCALE), using the crate’s default rounding mode for any
scale-down step.
Unlike the Self::mul_of family, the source width may be
wider than Self’s — the conversion is fallible and
returns ConvertError rather than requiring
WidthLE.
See Self::convert_from_with for the explicit-mode form,
the value-preserving width/scale ordering, and the full
list of error conditions.
Sourcepub fn convert_from_with<W1, const S1: u32>(
src: D<W1, S1>,
mode: RoundingMode,
) -> Result<Self, ConvertError>where
W1: BigInt,
pub fn convert_from_with<W1, const S1: u32>(
src: D<W1, S1>,
mode: RoundingMode,
) -> Result<Self, ConvertError>where
W1: BigInt,
Converts a source decimal of any storage width W1 and
any SCALE S1 to Self, using mode for any
scale-down rounding.
The conversion composes a cross-width and a cross-scale
step on the stored magnitude, ordered to be
value-preserving: when Self’s storage is at least as
wide as the source’s, the magnitude is widened first and
the scale change happens at the target width; when Self’s
storage is narrower, the scale change happens at the source
width first (so a value that is too large at S1 but fits
after a scale-down is not spuriously rejected) and the
magnitude is narrowed afterwards. The branch is chosen by a
compile-time limb-count comparison, so no nightly
generic_const_exprs is required.
§Rounding
A scale-up (S1 < SCALE) is exact. A scale-down
(S1 > SCALE) discards low fractional digits and rounds
them per mode; this is not an error.
§Errors
Returns ConvertError::Overflow when the scaled
magnitude does not fit Self’s storage — either a
scale-up overflows the working width, or the
(correctly-ordered) rescaled magnitude does not fit the
narrower target storage.
Sourcepub fn cmp_of<W2, const S2: u32>(self, other: D<W2, S2>) -> Ordering
pub fn cmp_of<W2, const S2: u32>(self, other: D<W2, S2>) -> Ordering
Compares self against other of any width ≤ Self’s
and any SCALE. Comparison is exact: both sides are
widened to Self’s storage and UP-rescaled to the
higher of SCALE / S2 (both UP-rescales are lossless),
then the storage Ord is invoked.
Sourcepub fn eq_of<W2, const S2: u32>(self, other: D<W2, S2>) -> bool
pub fn eq_of<W2, const S2: u32>(self, other: D<W2, S2>) -> bool
Returns true iff self == other (semantically; cross-
width / cross-SCALE). See Self::cmp_of for the
exactness contract.
Sourcepub fn ne_of<W2, const S2: u32>(self, other: D<W2, S2>) -> bool
pub fn ne_of<W2, const S2: u32>(self, other: D<W2, S2>) -> bool
Returns true iff self != other (semantically).
Sourcepub fn lt_of<W2, const S2: u32>(self, other: D<W2, S2>) -> bool
pub fn lt_of<W2, const S2: u32>(self, other: D<W2, S2>) -> bool
Returns true iff self < other (semantically).
Sourcepub fn le_of<W2, const S2: u32>(self, other: D<W2, S2>) -> bool
pub fn le_of<W2, const S2: u32>(self, other: D<W2, S2>) -> bool
Returns true iff self <= other (semantically).
Source§impl<const SCALE: u32> D38<SCALE>
impl<const SCALE: u32> D38<SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D38<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D38<TARGET_SCALE>
Rescales to TARGET_SCALE using the crate’s default
rounding mode (HalfToEven, or whatever a rounding-*
Cargo feature selects). Delegates to Self::rescale_with.
Sourcepub fn with_scale<const TARGET_SCALE: u32>(self) -> D38<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D38<TARGET_SCALE>
Builder-style alias for Self::rescale.
Returns a new value at TARGET_SCALE using the crate’s
default rounding mode. Use Self::rescale_with when
you need to pass an explicit RoundingMode.
Sourcepub fn rescale_with<const TARGET_SCALE: u32>(
self,
mode: RoundingMode,
) -> D38<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D38<TARGET_SCALE>
Rescales to TARGET_SCALE using the supplied rounding
mode.
TARGET_SCALE == SCALE: bit-identity.TARGET_SCALE > SCALE: scale-up multiplies by10^(TARGET - SCALE); lossless; panics on overflow.TARGET_SCALE < SCALE: scale-down divides by10^(SCALE - TARGET)with the requested rounding rule.
Trait Implementations§
Source§impl<const SCALE: u32> Add for D38<SCALE>
impl<const SCALE: u32> Add for D38<SCALE>
Source§fn add(self, rhs: Self) -> Self
fn add(self, rhs: Self) -> Self
Add two values of the same scale.
Panics on overflow in BOTH debug and release (a fixed-width
decimal never silently wraps a wrong number; use
Self::wrapping_add / Self::checked_add /
Self::saturating_add for the other policies).
Routes through the AddPolicy per-type policy trait.
Source§impl<const SCALE: u32> AddAssign for D38<SCALE>
impl<const SCALE: u32> AddAssign for D38<SCALE>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<const SCALE: u32> BitAndAssign for D38<SCALE>
impl<const SCALE: u32> BitAndAssign for D38<SCALE>
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl<const SCALE: u32> BitOrAssign for D38<SCALE>
impl<const SCALE: u32> BitOrAssign for D38<SCALE>
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl<const SCALE: u32> BitXorAssign for D38<SCALE>
impl<const SCALE: u32> BitXorAssign for D38<SCALE>
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moreSource§impl<const SCALE: u32> CheckedAdd for D38<SCALE>
impl<const SCALE: u32> CheckedAdd for D38<SCALE>
Source§fn checked_add(&self, rhs: &Self) -> Option<Self>
fn checked_add(&self, rhs: &Self) -> Option<Self>
None is
returned.Source§impl<const SCALE: u32> CheckedDiv for D38<SCALE>
impl<const SCALE: u32> CheckedDiv for D38<SCALE>
Source§fn checked_div(&self, rhs: &Self) -> Option<Self>
fn checked_div(&self, rhs: &Self) -> Option<Self>
None is returned.Source§impl<const SCALE: u32> CheckedMul for D38<SCALE>
impl<const SCALE: u32> CheckedMul for D38<SCALE>
Source§fn checked_mul(&self, rhs: &Self) -> Option<Self>
fn checked_mul(&self, rhs: &Self) -> Option<Self>
None is returned.Source§impl<const SCALE: u32> CheckedNeg for D38<SCALE>
impl<const SCALE: u32> CheckedNeg for D38<SCALE>
Source§fn checked_neg(&self) -> Option<Self>
fn checked_neg(&self) -> Option<Self>
None for results that can’t be represented, like signed MIN
values that can’t be positive, or non-zero unsigned values that can’t be negative. Read moreSource§impl<const SCALE: u32> CheckedRem for D38<SCALE>
impl<const SCALE: u32> CheckedRem for D38<SCALE>
Source§fn checked_rem(&self, rhs: &Self) -> Option<Self>
fn checked_rem(&self, rhs: &Self) -> Option<Self>
None is returned. Read moreSource§impl<const SCALE: u32> CheckedSub for D38<SCALE>
impl<const SCALE: u32> CheckedSub for D38<SCALE>
Source§fn checked_sub(&self, rhs: &Self) -> Option<Self>
fn checked_sub(&self, rhs: &Self) -> Option<Self>
None is returned.Source§impl<const SCALE: u32> DecimalArithmetic for D38<SCALE>
impl<const SCALE: u32> DecimalArithmetic for D38<SCALE>
Source§fn multiplier() -> Int<2>
fn multiplier() -> Int<2>
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)
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>,
Source§impl<const SCALE: u32> DecimalConvert for D38<SCALE>
impl<const SCALE: u32> DecimalConvert for D38<SCALE>
Source§fn to_int_with(self, mode: RoundingMode) -> i64
fn to_int_with(self, mode: RoundingMode) -> i64
i64 using the supplied rounding mode.Source§fn from_f64_with(value: f64, mode: RoundingMode) -> Self
fn from_f64_with(value: f64, mode: RoundingMode) -> Self
f64 using the supplied rounding mode.Source§impl<const SCALE: u32> DecimalTranscendental for D38<SCALE>
impl<const SCALE: u32> DecimalTranscendental for D38<SCALE>
Source§fn ln_strict(self) -> Self
fn ln_strict(self) -> Self
fn ln_strict_with(self, mode: RoundingMode) -> Self
fn ln_approx(self, working_digits: u32) -> Self
fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Source§fn log_strict(self, base: Self) -> Self
fn log_strict(self, base: Self) -> Self
fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
fn log_approx(self, base: Self, working_digits: u32) -> Self
fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Source§fn log2_strict(self) -> Self
fn log2_strict(self) -> Self
fn log2_strict_with(self, mode: RoundingMode) -> Self
fn log2_approx(self, working_digits: u32) -> Self
fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Source§fn log10_strict(self) -> Self
fn log10_strict(self) -> Self
fn log10_strict_with(self, mode: RoundingMode) -> Self
fn log10_approx(self, working_digits: u32) -> Self
fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn exp_strict(self) -> Self
fn exp_strict_with(self, mode: RoundingMode) -> Self
fn exp_approx(self, working_digits: u32) -> Self
fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn exp2_strict(self) -> Self
fn exp2_strict_with(self, mode: RoundingMode) -> Self
fn exp2_approx(self, working_digits: u32) -> Self
fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn powf_strict(self, exp: Self) -> Self
fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
fn powf_approx(self, exp: Self, working_digits: u32) -> Self
fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
fn sqrt_strict(self) -> Self
fn sqrt_strict_with(self, mode: RoundingMode) -> Self
fn cbrt_strict(self) -> Self
fn cbrt_strict_with(self, mode: RoundingMode) -> Self
fn hypot_strict(self, other: Self) -> Self
fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
fn sin_strict(self) -> Self
fn sin_strict_with(self, mode: RoundingMode) -> Self
fn sin_approx(self, working_digits: u32) -> Self
fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn cos_strict(self) -> Self
fn cos_strict_with(self, mode: RoundingMode) -> Self
fn cos_approx(self, working_digits: u32) -> Self
fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn tan_strict(self) -> Self
fn tan_strict_with(self, mode: RoundingMode) -> Self
fn tan_approx(self, working_digits: u32) -> Self
fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn atan_strict(self) -> Self
fn atan_strict_with(self, mode: RoundingMode) -> Self
fn atan_approx(self, working_digits: u32) -> Self
fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn asin_strict(self) -> Self
fn asin_strict_with(self, mode: RoundingMode) -> Self
fn asin_approx(self, working_digits: u32) -> Self
fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn acos_strict(self) -> Self
fn acos_strict_with(self, mode: RoundingMode) -> Self
fn acos_approx(self, working_digits: u32) -> Self
fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Source§fn atan2_strict(self, other: Self) -> Self
fn atan2_strict(self, other: Self) -> Self
atan2(self, other) — matches the f64 convention where
self is y and other is x.fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
fn atan2_approx(self, other: Self, working_digits: u32) -> Self
fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
fn sinh_strict(self) -> Self
fn sinh_strict_with(self, mode: RoundingMode) -> Self
fn sinh_approx(self, working_digits: u32) -> Self
fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn cosh_strict(self) -> Self
fn cosh_strict_with(self, mode: RoundingMode) -> Self
fn cosh_approx(self, working_digits: u32) -> Self
fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn tanh_strict(self) -> Self
fn tanh_strict_with(self, mode: RoundingMode) -> Self
fn tanh_approx(self, working_digits: u32) -> Self
fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn asinh_strict(self) -> Self
fn asinh_strict_with(self, mode: RoundingMode) -> Self
fn asinh_approx(self, working_digits: u32) -> Self
fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn acosh_strict(self) -> Self
fn acosh_strict_with(self, mode: RoundingMode) -> Self
fn acosh_approx(self, working_digits: u32) -> Self
fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn atanh_strict(self) -> Self
fn atanh_strict_with(self, mode: RoundingMode) -> Self
fn atanh_approx(self, working_digits: u32) -> Self
fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn to_degrees_strict(self) -> Self
fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
fn to_degrees_approx(self, working_digits: u32) -> Self
fn to_degrees_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
fn to_radians_strict(self) -> Self
fn to_radians_strict_with(self, mode: RoundingMode) -> Self
fn to_radians_approx(self, working_digits: u32) -> Self
fn to_radians_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Source§impl<const SCALE: u32> Div for D38<SCALE>
impl<const SCALE: u32> Div for D38<SCALE>
Source§fn div(self, rhs: Self) -> Self
fn div(self, rhs: Self) -> Self
Divide two values of the same scale using the crate-default
RoundingMode (within 0.5 ULP). Numerator is widened to
$Wider, multiplied by 10^SCALE, then divided by b
preserving the value · 10^SCALE form. See
Self::div_with for a non-default rounding mode.
Source§impl<const SCALE: u32> DivAssign for D38<SCALE>
impl<const SCALE: u32> DivAssign for D38<SCALE>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl<const SCALE: u32> FromPrimitive for D38<SCALE>
impl<const SCALE: u32> FromPrimitive for D38<SCALE>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl<const SCALE: u32> Mul for D38<SCALE>
impl<const SCALE: u32> Mul for D38<SCALE>
Source§fn mul(self, rhs: Self) -> Self
fn mul(self, rhs: Self) -> Self
Multiply two values of the same scale. Widens to $Wider
to hold a · b exactly, divides by 10^SCALE using the
crate-default RoundingMode (IEEE-754 round-to-nearest;
within 0.5 ULP), and narrows back to $Storage. See
Self::mul_with to choose a non-default rounding mode.
Source§impl<const SCALE: u32> MulAssign for D38<SCALE>
impl<const SCALE: u32> MulAssign for D38<SCALE>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl<const SCALE: u32> Neg for D38<SCALE>
impl<const SCALE: u32> Neg for D38<SCALE>
Source§fn neg(self) -> Self
fn neg(self) -> Self
Negate a value. Panics on overflow in BOTH debug and release
(-MIN is unrepresentable in two’s-complement; use
Self::wrapping_neg / Self::checked_neg /
Self::saturating_neg for the other policies).
Routes through the NegPolicy per-type policy trait.
Source§impl<const SCALE: u32> Num for D38<SCALE>
impl<const SCALE: u32> Num for D38<SCALE>
type FromStrRadixErr = ParseError
Source§fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36). Read moreSource§impl<const SCALE: u32> Rem for D38<SCALE>
impl<const SCALE: u32> Rem for D38<SCALE>
Source§fn rem(self, rhs: Self) -> Self
fn rem(self, rhs: Self) -> Self
Remainder of two values at the same scale. Because both operands share the scale factor, the storage-level remainder is the answer with no rescaling.
Panics on the MIN % -ONE overflow boundary in BOTH debug
and release; division by zero always panics (use
Self::wrapping_rem / Self::checked_rem for the other
policies).
Routes through the RemPolicy per-type policy trait.
Source§impl<const SCALE: u32> RemAssign for D38<SCALE>
impl<const SCALE: u32> RemAssign for D38<SCALE>
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read moreSource§impl<const SCALE: u32> ShlAssign<u32> for D38<SCALE>
impl<const SCALE: u32> ShlAssign<u32> for D38<SCALE>
Source§fn shl_assign(&mut self, n: u32)
fn shl_assign(&mut self, n: u32)
<<= operation. Read moreSource§impl<const SCALE: u32> ShrAssign<u32> for D38<SCALE>
impl<const SCALE: u32> ShrAssign<u32> for D38<SCALE>
Source§fn shr_assign(&mut self, n: u32)
fn shr_assign(&mut self, n: u32)
>>= operation. Read moreSource§impl<const SCALE: u32> Signed for D38<SCALE>
impl<const SCALE: u32> Signed for D38<SCALE>
Source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Source§impl<const SCALE: u32> Sub for D38<SCALE>
impl<const SCALE: u32> Sub for D38<SCALE>
Source§fn sub(self, rhs: Self) -> Self
fn sub(self, rhs: Self) -> Self
Subtract two values of the same scale.
Panics on overflow in BOTH debug and release (use
Self::wrapping_sub / Self::checked_sub /
Self::saturating_sub for the other policies).
Routes through the SubPolicy per-type policy trait.
Source§impl<const SCALE: u32> SubAssign for D38<SCALE>
impl<const SCALE: u32> SubAssign for D38<SCALE>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreSource§impl<const SCALE: u32> ToPrimitive for D38<SCALE>
impl<const SCALE: u32> ToPrimitive for D38<SCALE>
Source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self to an i64. If the value cannot be
represented by an i64, then None is returned.Source§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self to a u64. If the value cannot be
represented by a u64, then None is returned.Source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self to an i128. If the value cannot be
represented by an i128 (i64 under the default implementation), then
None is returned. Read moreSource§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
self to a u128. If the value cannot be
represented by a u128 (u64 under the default implementation), then
None is returned. Read moreSource§fn to_f32(&self) -> Option<f32>
fn to_f32(&self) -> Option<f32>
self to an f32. Overflows may map to positive
or negative inifinity, otherwise None is returned if the value cannot
be represented by an f32.Source§fn to_f64(&self) -> Option<f64>
fn to_f64(&self) -> Option<f64>
self to an f64. Overflows may map to positive
or negative inifinity, otherwise None is returned if the value cannot
be represented by an f64. Read moreSource§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self to an isize. If the value cannot be
represented by an isize, then None is returned.Source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self to an i8. If the value cannot be
represented by an i8, then None is returned.Source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self to an i16. If the value cannot be
represented by an i16, then None is returned.Source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self to an i32. If the value cannot be
represented by an i32, then None is returned.Source§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self to a usize. If the value cannot be
represented by a usize, then None is returned.Source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self to a u8. If the value cannot be
represented by a u8, then None is returned.Source§impl<const SCALE: u32> TryFrom<D<Int<3>, SCALE>> for D38<SCALE>
impl<const SCALE: u32> TryFrom<D<Int<3>, SCALE>> for D38<SCALE>
Source§fn try_from(value: D57<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D57<SCALE>) -> Result<Self, Self::Error>
Attempts to narrow a wider decimal type to this narrower
one. Fails with Overflow when the source value exceeds
the destination’s MIN..=MAX. The scale is unchanged.
Source§type Error = ConvertError
type Error = ConvertError
Source§impl<const SCALE: u32> TryFrom<D<Int<4>, SCALE>> for D38<SCALE>
impl<const SCALE: u32> TryFrom<D<Int<4>, SCALE>> for D38<SCALE>
Source§fn try_from(value: D76<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D76<SCALE>) -> Result<Self, Self::Error>
Attempts to narrow a wider decimal type to this narrower
one. Fails with Overflow when the source value exceeds
the destination’s MIN..=MAX. The scale is unchanged.
Source§type Error = ConvertError
type Error = ConvertError
Source§impl<const SCALE: u32> TryFrom<D<Int<8>, SCALE>> for D38<SCALE>
impl<const SCALE: u32> TryFrom<D<Int<8>, SCALE>> for D38<SCALE>
Source§fn try_from(value: D153<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D153<SCALE>) -> Result<Self, Self::Error>
Attempts to narrow a wider decimal type to this narrower
one. Fails with Overflow when the source value exceeds
the destination’s MIN..=MAX. The scale is unchanged.