#[repr(transparent)]pub struct D9<const SCALE: u32>(pub i32);Expand description
Scaled fixed-point decimal with 32-bit storage. See D38 for the
shape documentation; D9 has the same surface scaled to i32 and
MAX_SCALE = 9.
Tuple Fields§
§0: i32Implementations§
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub fn from_int(value: i32) -> Self
pub fn from_int(value: i32) -> Self
Constructs from an integer at the widest supported source,
scaling by 10^SCALE. Overflow follows Rust’s default
integer arithmetic (debug panic, release wrap).
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 integer part
of the rounded value 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> D9<SCALE>
impl<const SCALE: u32> D9<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.
Arithmetic that overflows this bound panics in debug builds and wraps in release builds.
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 debug
builds because two’s-complement MIN has no positive
counterpart.
Sourcepub const fn from_bits(raw: i32) -> Self
pub const fn from_bits(raw: i32) -> 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) -> i32
pub const fn to_bits(self) -> i32
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() -> i32
pub const fn multiplier() -> i32
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> D9<SCALE>
impl<const SCALE: u32> D9<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. Within 0.5 ULP
for the half-* family.
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.
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<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> D9<SCALE>
impl<const SCALE: u32> D9<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 widens to $Wider
so widening overflow is detected before the narrowing
step.
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.
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 — true if the exact product
would be out of Self’s 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 quotient would overflow Self. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Panics on divide-by-zero
(matches i128::wrapping_div semantics).
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 with
a boolean — true if the exact quotient was out of
range or rhs was zero.
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub const fn abs(self) -> Self
pub const fn abs(self) -> Self
Returns the absolute value of self.
Note: abs(MIN) overflows (because |MIN| has no positive
counterpart in two’s complement). Debug builds panic;
release builds wrap.
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> D9<SCALE>
impl<const SCALE: u32> D9<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 (HalfToEven, or whichever a rounding-* Cargo
feature selects). 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> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
ln_strict — delegates to crate::core_type::D38::ln_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
log2_strict — delegates to crate::core_type::D38::log2_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
log10_strict — delegates to crate::core_type::D38::log10_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
exp_strict — delegates to crate::core_type::D38::exp_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
exp2_strict — delegates to crate::core_type::D38::exp2_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
sqrt_strict — delegates to crate::core_type::D38::sqrt_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
cbrt_strict — delegates to crate::core_type::D38::cbrt_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
sin_strict — delegates to crate::core_type::D38::sin_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
cos_strict — delegates to crate::core_type::D38::cos_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
tan_strict — delegates to crate::core_type::D38::tan_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
asin_strict — delegates to crate::core_type::D38::asin_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
acos_strict — delegates to crate::core_type::D38::acos_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
atan_strict — delegates to crate::core_type::D38::atan_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
sinh_strict — delegates to crate::core_type::D38::sinh_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
cosh_strict — delegates to crate::core_type::D38::cosh_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
tanh_strict — delegates to crate::core_type::D38::tanh_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
asinh_strict — delegates to crate::core_type::D38::asinh_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
acosh_strict — delegates to crate::core_type::D38::acosh_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
atanh_strict — delegates to crate::core_type::D38::atanh_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
to_degrees_strict — delegates to crate::core_type::D38::to_degrees_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
to_radians_strict — delegates to crate::core_type::D38::to_radians_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
log_strict — delegates to crate::core_type::D38::log_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
atan2_strict — delegates to crate::core_type::D38::atan2_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
powf_strict — delegates to crate::core_type::D38::powf_strict via widen → strict → narrow. 0.5 ULP correctly-rounded at storage scale. Panics if the result doesn’t fit Self’s range.
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
ln — feature-gated dispatcher; forwards to Self::ln_strict when the strict feature is on.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
log2 — feature-gated dispatcher; forwards to Self::log2_strict when the strict feature is on.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
log10 — feature-gated dispatcher; forwards to Self::log10_strict when the strict feature is on.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
exp — feature-gated dispatcher; forwards to Self::exp_strict when the strict feature is on.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
exp2 — feature-gated dispatcher; forwards to Self::exp2_strict when the strict feature is on.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
sqrt — feature-gated dispatcher; forwards to Self::sqrt_strict when the strict feature is on.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
cbrt — feature-gated dispatcher; forwards to Self::cbrt_strict when the strict feature is on.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
sin — feature-gated dispatcher; forwards to Self::sin_strict when the strict feature is on.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
cos — feature-gated dispatcher; forwards to Self::cos_strict when the strict feature is on.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
tan — feature-gated dispatcher; forwards to Self::tan_strict when the strict feature is on.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
asin — feature-gated dispatcher; forwards to Self::asin_strict when the strict feature is on.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
acos — feature-gated dispatcher; forwards to Self::acos_strict when the strict feature is on.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
atan — feature-gated dispatcher; forwards to Self::atan_strict when the strict feature is on.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
sinh — feature-gated dispatcher; forwards to Self::sinh_strict when the strict feature is on.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
cosh — feature-gated dispatcher; forwards to Self::cosh_strict when the strict feature is on.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
tanh — feature-gated dispatcher; forwards to Self::tanh_strict when the strict feature is on.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
asinh — feature-gated dispatcher; forwards to Self::asinh_strict when the strict feature is on.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
acosh — feature-gated dispatcher; forwards to Self::acosh_strict when the strict feature is on.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
atanh — feature-gated dispatcher; forwards to Self::atanh_strict when the strict feature is on.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
to_degrees — feature-gated dispatcher; forwards to Self::to_degrees_strict when the strict feature is on.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
to_radians — feature-gated dispatcher; forwards to Self::to_radians_strict when the strict feature is on.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
log — feature-gated dispatcher; forwards to Self::log_strict when the strict feature is on.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
atan2 — feature-gated dispatcher; forwards to Self::atan2_strict when the strict feature is on.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
powf — feature-gated dispatcher; forwards to Self::powf_strict when the strict feature is on.
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub fn log10_fast(self) -> Self
pub fn log10_fast(self) -> Self
Base-10 logarithm via the f64 bridge.
Sourcepub fn hypot_fast(self, other: Self) -> Self
pub fn hypot_fast(self, other: Self) -> Self
sqrt(self^2 + other^2) via the f64 bridge.
Sourcepub fn atan2_fast(self, other: Self) -> Self
pub fn atan2_fast(self, other: Self) -> Self
Four-quadrant arctangent via the f64 bridge.
Sourcepub fn asinh_fast(self) -> Self
pub fn asinh_fast(self) -> Self
Inverse hyperbolic sine via the f64 bridge.
Sourcepub fn acosh_fast(self) -> Self
pub fn acosh_fast(self) -> Self
Inverse hyperbolic cosine via the f64 bridge.
Sourcepub fn atanh_fast(self) -> Self
pub fn atanh_fast(self) -> Self
Inverse hyperbolic tangent via the f64 bridge.
Sourcepub fn to_degrees_fast(self) -> Self
pub fn to_degrees_fast(self) -> Self
Radians → degrees via the f64 bridge.
Sourcepub fn to_radians_fast(self) -> Self
pub fn to_radians_fast(self) -> Self
Degrees → radians via the f64 bridge.
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub fn pow(self, exp: u32) -> Self
pub fn pow(self, exp: u32) -> Self
Raises self to the power exp via square-and-multiply.
exp = 0 always returns ONE. Overflow at any
multiplication step follows the Mul operator’s
semantics (debug-panic, release-wrap).
Sourcepub fn powi(self, exp: i32) -> Self
pub fn powi(self, exp: i32) -> Self
Signed integer exponent. For non-negative exp this is
self.pow(exp as u32); for negative exp it is
Self::ONE / self.pow(exp.unsigned_abs()).
i32::unsigned_abs handles i32::MIN without the
signed-negation overflow that (-i32::MIN) as u32
would cause.
Sourcepub fn checked_pow(self, exp: u32) -> Option<Self>
pub fn checked_pow(self, exp: u32) -> Option<Self>
Some(self^exp), or None if any multiplication step
overflows.
Sourcepub fn wrapping_pow(self, exp: u32) -> Self
pub fn wrapping_pow(self, exp: u32) -> Self
Two’s-complement wrap at every multiplication step.
Sourcepub fn saturating_pow(self, exp: u32) -> Self
pub fn saturating_pow(self, exp: u32) -> Self
Saturates to Self::MAX or Self::MIN on overflow,
based on the sign the mathematical result would have.
Sourcepub fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub fn overflowing_pow(self, exp: u32) -> (Self, bool)
(self^exp, overflowed). overflowed is true if any
multiplication step overflowed; the value is the
wrapping form.
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub const fn unsigned_shr(self, n: u32) -> Self
pub const 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 const fn rotate_left(self, n: u32) -> Self
pub const fn rotate_left(self, n: u32) -> Self
Rotate the raw storage left by n bits.
Sourcepub const fn rotate_right(self, n: u32) -> Self
pub const fn rotate_right(self, n: u32) -> Self
Rotate the raw storage right by n bits.
Sourcepub const fn leading_zeros(self) -> u32
pub const fn leading_zeros(self) -> u32
Number of leading zero bits in the raw storage.
Sourcepub const fn trailing_zeros(self) -> u32
pub const fn trailing_zeros(self) -> u32
Number of trailing zero bits in the raw storage.
Sourcepub const fn count_ones(self) -> u32
pub const fn count_ones(self) -> u32
Population count of the raw storage.
Sourcepub const fn count_zeros(self) -> u32
pub const fn count_zeros(self) -> u32
Number of zero bits in the raw storage.
Sourcepub const fn is_power_of_two(self) -> bool
pub const fn is_power_of_two(self) -> bool
true if the raw storage, viewed as unsigned, is a power
of two.
Sourcepub const fn next_power_of_two(self) -> Self
pub const 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> D9<SCALE>
impl<const SCALE: u32> D9<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> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub fn div_floor(self, rhs: Self) -> Self
pub fn div_floor(self, rhs: Self) -> Self
Floor-rounded division: floor(self / rhs) as an integer
multiple of ONE. Panics on rhs == ZERO.
Inlined rather than using i128::div_floor, which is
still unstable for signed types.
Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub fn widen(self) -> D18<SCALE>
pub fn widen(self) -> D18<SCALE>
Promote to the next storage tier (D18) at the same SCALE.
Lossless — every D9<SCALE> value fits D18<SCALE> by
construction (i32::MAX < i64::MAX). Chains via further
widen calls if you need to climb to D38 / D76 / etc.
use decimal_scaled::D9s6;
let a = D9s6::from_int(123);
let b = a.widen(); // D18<6>
assert_eq!(b.to_bits(), a.to_bits() as i64);Source§impl<const SCALE: u32> D9<SCALE>
impl<const SCALE: u32> D9<SCALE>
Sourcepub const fn rescale<const TARGET_SCALE: u32>(self) -> D9<TARGET_SCALE>
pub const fn rescale<const TARGET_SCALE: u32>(self) -> D9<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; see that method for
scale-up / scale-down semantics and the overflow policy.
Sourcepub const fn with_scale<const TARGET_SCALE: u32>(self) -> D9<TARGET_SCALE>
pub const fn with_scale<const TARGET_SCALE: u32>(self) -> D9<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 const fn rescale_with<const TARGET_SCALE: u32>(
self,
mode: RoundingMode,
) -> D9<TARGET_SCALE>
pub const fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D9<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> AddAssign for D9<SCALE>
impl<const SCALE: u32> AddAssign for D9<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 D9<SCALE>
impl<const SCALE: u32> BitAndAssign for D9<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 D9<SCALE>
impl<const SCALE: u32> BitOrAssign for D9<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 D9<SCALE>
impl<const SCALE: u32> BitXorAssign for D9<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 D9<SCALE>
impl<const SCALE: u32> CheckedAdd for D9<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 D9<SCALE>
impl<const SCALE: u32> CheckedDiv for D9<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 D9<SCALE>
impl<const SCALE: u32> CheckedMul for D9<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 D9<SCALE>
impl<const SCALE: u32> CheckedNeg for D9<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 D9<SCALE>
impl<const SCALE: u32> CheckedRem for D9<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 D9<SCALE>
impl<const SCALE: u32> CheckedSub for D9<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> Decimal for D9<SCALE>
impl<const SCALE: u32> Decimal for D9<SCALE>
Source§const SCALE: u32 = SCALE
const SCALE: u32 = SCALE
10^-SCALE.Source§const MAX_SCALE: u32 = 9
const MAX_SCALE: u32 = 9
SCALE for this width. Equal to the largest
k such that 10^k fits in Self::Storage. For example, 38
for D38, 76 for D76.Source§const MAX: Self = D9<SCALE>::MAX
const MAX: Self = D9<SCALE>::MAX
Self::Storage::MAX).Source§const MIN: Self = D9<SCALE>::MIN
const MIN: Self = D9<SCALE>::MIN
Self::Storage::MIN).Source§fn multiplier() -> i32
fn multiplier() -> i32
10^SCALE, the factor that converts a logical integer
to its storage representation.Source§fn scale(self) -> u32
fn scale(self) -> u32
Self::SCALE; provided for ergonomic method-call syntax).Source§fn abs(self) -> Self
fn abs(self) -> Self
Self::MIN.abs() panics in debug, wraps to
Self::MIN in release (mirroring the storage type).Source§fn is_positive(self) -> bool
fn is_positive(self) -> bool
true when self > ZERO.Source§fn is_negative(self) -> bool
fn is_negative(self) -> bool
true when self < ZERO.Source§fn is_infinite(self) -> bool
fn is_infinite(self) -> bool
false — fixed-point decimals cannot represent infinity.Source§fn div_euclid(self, rhs: Self) -> Self
fn div_euclid(self, rhs: Self) -> Self
Self. Panics on rhs == ZERO.Source§fn rem_euclid(self, rhs: Self) -> Self
fn rem_euclid(self, rhs: Self) -> Self
rhs != ZERO. Panics on
rhs == ZERO.Source§fn div_floor(self, rhs: Self) -> Self
fn div_floor(self, rhs: Self) -> Self
-∞). Panics on rhs == ZERO.Source§fn div_ceil(self, rhs: Self) -> Self
fn div_ceil(self, rhs: Self) -> Self
+∞). Panics on rhs == ZERO.Source§fn midpoint(self, rhs: Self) -> Self
fn midpoint(self, rhs: Self) -> Self
self and rhs (rounding toward -∞), computed
without intermediate overflow.Source§fn mul_add(self, a: Self, b: Self) -> Self
fn mul_add(self, a: Self, b: Self) -> Self
self * a + b — mirrors the f64::mul_add call shape so
f64-generic numeric code can monomorphise to a decimal type.Source§fn pow(self, exp: u32) -> Self
fn pow(self, exp: u32) -> Self
self^exp via square-and-multiply. Overflow follows Mul
(debug panic, release wrap).Source§fn powi(self, exp: i32) -> Self
fn powi(self, exp: i32) -> Self
exp produces
ONE / self.pow(|exp|); the divide truncates at the type’s
scale.Source§fn checked_pow(self, exp: u32) -> Option<Self>
fn checked_pow(self, exp: u32) -> Option<Self>
Some(self^exp), or None if any intermediate step overflows.Source§fn wrapping_pow(self, exp: u32) -> Self
fn wrapping_pow(self, exp: u32) -> Self
pow. Each multiplication step wraps in the storage
type.Source§fn saturating_pow(self, exp: u32) -> Self
fn saturating_pow(self, exp: u32) -> Self
pow — clamps to MAX / MIN on overflow, with
the sign matching the mathematical result.Source§fn overflowing_pow(self, exp: u32) -> (Self, bool)
fn overflowing_pow(self, exp: u32) -> (Self, bool)
(self^exp, overflowed) — the wrapping result paired with a
boolean.Source§fn checked_add(self, rhs: Self) -> Option<Self>
fn checked_add(self, rhs: Self) -> Option<Self>
Some(self + rhs), or None if the sum overflows.Source§fn checked_sub(self, rhs: Self) -> Option<Self>
fn checked_sub(self, rhs: Self) -> Option<Self>
Some(self - rhs), or None if the difference overflows.Source§fn checked_mul(self, rhs: Self) -> Option<Self>
fn checked_mul(self, rhs: Self) -> Option<Self>
Some(self * rhs), or None if the scaled product overflows.Source§fn checked_div(self, rhs: Self) -> Option<Self>
fn checked_div(self, rhs: Self) -> Option<Self>
Some(self / rhs), or None if rhs == ZERO or the quotient
overflows the storage.Source§fn checked_neg(self) -> Option<Self>
fn checked_neg(self) -> Option<Self>
Some(-self), or None when self == MIN.Source§fn checked_rem(self, rhs: Self) -> Option<Self>
fn checked_rem(self, rhs: Self) -> Option<Self>
Some(self % rhs), or None on divide-by-zero / MIN % -ONE.Source§fn wrapping_add(self, rhs: Self) -> Self
fn wrapping_add(self, rhs: Self) -> Self
+.Source§fn wrapping_sub(self, rhs: Self) -> Self
fn wrapping_sub(self, rhs: Self) -> Self
-.Source§fn wrapping_mul(self, rhs: Self) -> Self
fn wrapping_mul(self, rhs: Self) -> Self
* — intermediate widens for overflow detection, the
final narrowing wraps.Source§fn wrapping_div(self, rhs: Self) -> Self
fn wrapping_div(self, rhs: Self) -> Self
/ — panics on rhs == ZERO, matching
i128::wrapping_div.Source§fn wrapping_neg(self) -> Self
fn wrapping_neg(self) -> Self
-self; MIN.wrapping_neg() == MIN.Source§fn wrapping_rem(self, rhs: Self) -> Self
fn wrapping_rem(self, rhs: Self) -> Self
% — panics on rhs == ZERO.Source§fn saturating_add(self, rhs: Self) -> Self
fn saturating_add(self, rhs: Self) -> Self
+.Source§fn saturating_sub(self, rhs: Self) -> Self
fn saturating_sub(self, rhs: Self) -> Self
-.Source§fn saturating_mul(self, rhs: Self) -> Self
fn saturating_mul(self, rhs: Self) -> Self
* — sign of the saturated bound matches the
mathematical product.Source§fn saturating_div(self, rhs: Self) -> Self
fn saturating_div(self, rhs: Self) -> Self
/ — divide-by-zero saturates to MAX / MIN
according to the sign of self.Source§fn saturating_neg(self) -> Self
fn saturating_neg(self) -> Self
-self — MIN.saturating_neg() == MAX.Source§fn overflowing_add(self, rhs: Self) -> (Self, bool)
fn overflowing_add(self, rhs: Self) -> (Self, bool)
+.Source§fn overflowing_sub(self, rhs: Self) -> (Self, bool)
fn overflowing_sub(self, rhs: Self) -> (Self, bool)
-.Source§fn overflowing_mul(self, rhs: Self) -> (Self, bool)
fn overflowing_mul(self, rhs: Self) -> (Self, bool)
*.Source§fn overflowing_div(self, rhs: Self) -> (Self, bool)
fn overflowing_div(self, rhs: Self) -> (Self, bool)
/ — overflowed is true on out-of-range or
divide-by-zero.Source§fn overflowing_neg(self) -> (Self, bool)
fn overflowing_neg(self) -> (Self, bool)
-self — overflowed is true iff self == MIN.Source§fn overflowing_rem(self, rhs: Self) -> (Self, bool)
fn overflowing_rem(self, rhs: Self) -> (Self, bool)
%.Source§fn from_i32(value: i32) -> Self
fn from_i32(value: i32) -> Self
i32, scaling by 10^SCALE. Width-generic
integer constructor; for wider source integers use the
concrete type’s from_int (whose IntSrc parameter varies
per width).Source§fn to_int(self) -> i64
fn to_int(self) -> i64
i64 using the crate-default rounding mode, with
saturating overflow on out-of-range integer parts.Source§fn to_int_with(self, mode: RoundingMode) -> i64
fn to_int_with(self, mode: RoundingMode) -> i64
i64 using the supplied rounding mode for the
fractional discard step. Saturating overflow on out-of-range
integer parts.Source§fn from_f64(value: f64) -> Self
fn from_f64(value: f64) -> Self
f64 using the crate-default rounding mode.
NaN saturates to ZERO; ±∞ saturates to MAX / MIN.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§fn to_f64(self) -> f64
fn to_f64(self) -> f64
f64. Lossy when the storage magnitude exceeds
f64’s ~15-digit exact range.Source§fn is_normal(self) -> bool
fn is_normal(self) -> bool
true for every non-zero value (a fixed-point decimal has no
subnormals).Source§fn sum<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Self>,
fn sum<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Self>,
ZERO. Width-generic convenience for iter.fold(ZERO, +).Source§fn product<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Self>,
fn product<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = Self>,
ONE. Width-generic convenience for iter.fold(ONE, *).Source§impl<const SCALE: u32> DecimalConsts for D9<SCALE>
impl<const SCALE: u32> DecimalConsts for D9<SCALE>
Source§fn quarter_pi() -> Self
fn quarter_pi() -> Self
Source§impl<const SCALE: u32> Div for D9<SCALE>
impl<const SCALE: u32> Div for D9<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 D9<SCALE>
impl<const SCALE: u32> DivAssign for D9<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 D9<SCALE>
impl<const SCALE: u32> FromPrimitive for D9<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 D9<SCALE>
impl<const SCALE: u32> Mul for D9<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 D9<SCALE>
impl<const SCALE: u32> MulAssign for D9<SCALE>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl<const SCALE: u32> Num for D9<SCALE>
impl<const SCALE: u32> Num for D9<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> Ord for D9<SCALE>
impl<const SCALE: u32> Ord for D9<SCALE>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<const SCALE: u32> PartialOrd for D9<SCALE>
impl<const SCALE: u32> PartialOrd for D9<SCALE>
Source§impl<const SCALE: u32> RemAssign for D9<SCALE>
impl<const SCALE: u32> RemAssign for D9<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 D9<SCALE>
impl<const SCALE: u32> ShlAssign<u32> for D9<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 D9<SCALE>
impl<const SCALE: u32> ShrAssign<u32> for D9<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 D9<SCALE>
impl<const SCALE: u32> Signed for D9<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> SubAssign for D9<SCALE>
impl<const SCALE: u32> SubAssign for D9<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 D9<SCALE>
impl<const SCALE: u32> ToPrimitive for D9<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<D18<SCALE>> for D9<SCALE>
impl<const SCALE: u32> TryFrom<D18<SCALE>> for D9<SCALE>
Source§fn try_from(value: D18<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D18<SCALE>) -> Result<Self, Self::Error>
Attempts to narrow a wider decimal type to this narrower
one. Fails with OutOfRange 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<D38<SCALE>> for D9<SCALE>
impl<const SCALE: u32> TryFrom<D38<SCALE>> for D9<SCALE>
Source§fn try_from(value: D38<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D38<SCALE>) -> Result<Self, Self::Error>
Attempts to narrow a wider decimal type to this narrower
one. Fails with OutOfRange 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<D76<SCALE>> for D9<SCALE>
impl<const SCALE: u32> TryFrom<D76<SCALE>> for D9<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.