#[repr(transparent)]pub struct D<S, const SCALE: u32>(pub S);Expand description
Generic scaled fixed-point decimal: storage integer S, base-10
scale SCALE. The logical value is self.0 / 10^SCALE.
See the module docs for the parameterisation contract.
Tuple Fields§
§0: SImplementations§
Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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 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: i128) -> Self
pub const fn from_bits(raw: i128) -> 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) -> i128
pub const fn to_bits(self) -> i128
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() -> i128
pub const fn multiplier() -> i128
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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub fn from_int(value: i64) -> Self
pub fn from_int(value: i64) -> 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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, SCALE>
Sourcepub fn from_int(value: i64) -> Self
pub fn from_int(value: i64) -> 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub fn narrow(self) -> Result<D18<SCALE>, ConvertError>
pub fn narrow(self) -> Result<D18<SCALE>, ConvertError>
Demote to the previous storage tier (D18) at the same
SCALE. Returns Err(ConvertError::OutOfRange) if the value
doesn’t fit i64’s range at the given scale.
use decimal_scaled::D38s9;
let a = D38s9::from_int(1_000_000);
let b = a.narrow().unwrap();
assert_eq!(b.to_bits() as i128, a.to_bits());Source§impl<const SCALE: u32> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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 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: 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
ln_strict — delegates to the policy-registered ln
kernel for this (width, SCALE) cell. 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::types::widths::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::types::widths::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 the policy-registered exp
kernel for this (width, SCALE) cell. 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::types::widths::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 the policy-registered sqrt
kernel for this (width, SCALE) cell. 0.5 ULP
correctly-rounded at storage scale. Panics if the
result doesn’t fit Self’s range.
For the narrow tier this resolves to
algos::sqrt::widen_to_d38 (widen → D38 sqrt
→ narrow); see policy::sqrt for the cascade.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
cbrt_strict — delegates to the policy-registered cbrt
kernel for this (width, SCALE) cell. 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 the policy-registered sin
kernel for this (width, SCALE) cell.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
cos_strict — delegates to the policy-registered cos
kernel for this (width, SCALE) cell.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
tan_strict — delegates to the policy-registered tan
kernel for this (width, SCALE) cell.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
asin_strict — delegates to the policy-registered asin
kernel for this (width, SCALE) cell.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
acos_strict — delegates to the policy-registered acos
kernel for this (width, SCALE) cell.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
atan_strict — delegates to the policy-registered atan
kernel for this (width, SCALE) cell.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
sinh_strict — delegates to crate::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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 the policy-registered atan2
kernel for this (width, SCALE) cell.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
powf_strict — delegates to the policy-registered powf
kernel for this (width, SCALE) cell. 0.5 ULP
correctly-rounded at storage scale. Panics if the
result doesn’t fit Self’s range.
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, SCALE>
Source§impl<const SCALE: u32> D<i32, SCALE>
impl<const SCALE: u32> D<i32, SCALE>
Source§impl<const SCALE: u32> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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 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: i64) -> Self
pub const fn from_bits(raw: i64) -> 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) -> i64
pub const fn to_bits(self) -> i64
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() -> i64
pub const fn multiplier() -> i64
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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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.
For SCALE = 0 the multiplier is 1; the i128 product is
returned directly. For SCALE >= 1 the divide-by-
10^SCALE step uses
i128_divrem_by_u64_with_mode, replacing the
__divti3 soft-call with two hardware divq instructions.
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 numerator is a · 10^SCALE as i128; the divisor
is rhs.0 cast to its unsigned-magnitude u64. The
final divide is the same u128/u64 schoolbook fast path
that Self::mul_with uses.
Source§impl<const SCALE: u32> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
ln_strict — delegates to the policy-registered ln
kernel for this (width, SCALE) cell. 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::types::widths::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::types::widths::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 the policy-registered exp
kernel for this (width, SCALE) cell. 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::types::widths::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 the policy-registered sqrt
kernel for this (width, SCALE) cell. 0.5 ULP
correctly-rounded at storage scale. Panics if the
result doesn’t fit Self’s range.
For the narrow tier this resolves to
algos::sqrt::widen_to_d38 (widen → D38 sqrt
→ narrow); see policy::sqrt for the cascade.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
cbrt_strict — delegates to the policy-registered cbrt
kernel for this (width, SCALE) cell. 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 the policy-registered sin
kernel for this (width, SCALE) cell.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
cos_strict — delegates to the policy-registered cos
kernel for this (width, SCALE) cell.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
tan_strict — delegates to the policy-registered tan
kernel for this (width, SCALE) cell.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
asin_strict — delegates to the policy-registered asin
kernel for this (width, SCALE) cell.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
acos_strict — delegates to the policy-registered acos
kernel for this (width, SCALE) cell.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
atan_strict — delegates to the policy-registered atan
kernel for this (width, SCALE) cell.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
sinh_strict — delegates to crate::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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::types::widths::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 the policy-registered atan2
kernel for this (width, SCALE) cell.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
powf_strict — delegates to the policy-registered powf
kernel for this (width, SCALE) cell. 0.5 ULP
correctly-rounded at storage scale. Panics if the
result doesn’t fit Self’s range.
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, SCALE>
Source§impl<const SCALE: u32> D<i64, SCALE>
impl<const SCALE: u32> D<i64, SCALE>
Source§impl<const SCALE: u32> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, 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> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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> D<i64, SCALE>
impl<const SCALE: u32> D<i64, SCALE>
Sourcepub fn widen(self) -> D38<SCALE>
pub fn widen(self) -> D38<SCALE>
Promote to the next storage tier (D38) at the same SCALE.
Lossless.
use decimal_scaled::D18s9;
let a = D18s9::from_int(7);
let b = a.widen(); // D38<9>
assert_eq!(b.to_bits(), a.to_bits() as i128);Sourcepub fn narrow(self) -> Result<D9<SCALE>, ConvertError>
pub fn narrow(self) -> Result<D9<SCALE>, ConvertError>
Demote to the previous storage tier (D9) at the same
SCALE.
§Errors
Returns Err(ConvertError::OutOfRange) if the value doesn’t
fit i32’s range at the given scale.
use decimal_scaled::D18s5;
let a = D18s5::from_int(7);
let b = a.narrow().unwrap(); // D9<5>
assert_eq!(b.to_bits() as i64, a.to_bits());Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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 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: Int256) -> Self
pub const fn from_bits(raw: Int256) -> 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) -> Int256
pub const fn to_bits(self) -> Int256
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() -> Int256
pub const fn multiplier() -> Int256
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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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.
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.
Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, SCALE>
Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, SCALE>
Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, 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> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D76<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D76<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) -> D76<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D76<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,
) -> D76<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D76<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.
Source§impl<const SCALE: u32> D<Int256, SCALE>
impl<const SCALE: u32> D<Int256, SCALE>
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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 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: Int512) -> Self
pub const fn from_bits(raw: Int512) -> 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) -> Int512
pub const fn to_bits(self) -> Int512
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() -> Int512
pub const fn multiplier() -> Int512
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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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.
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.
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, SCALE>
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, SCALE>
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, 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> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D153<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D153<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) -> D153<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D153<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,
) -> D153<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D153<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.
Source§impl<const SCALE: u32> D<Int512, SCALE>
impl<const SCALE: u32> D<Int512, SCALE>
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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 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: Int1024) -> Self
pub const fn from_bits(raw: Int1024) -> 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) -> Int1024
pub const fn to_bits(self) -> Int1024
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() -> Int1024
pub const fn multiplier() -> Int1024
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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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.
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.
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, 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> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D307<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D307<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) -> D307<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D307<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,
) -> D307<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D307<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.
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Source§impl<const SCALE: u32> D<Int1024, SCALE>
impl<const SCALE: u32> D<Int1024, SCALE>
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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 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: Int192) -> Self
pub const fn from_bits(raw: Int192) -> 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) -> Int192
pub const fn to_bits(self) -> Int192
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() -> Int192
pub const fn multiplier() -> Int192
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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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.
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.
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, SCALE>
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, SCALE>
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, 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> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D57<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D57<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) -> D57<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D57<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,
) -> D57<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D57<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.
Source§impl<const SCALE: u32> D<Int192, SCALE>
impl<const SCALE: u32> D<Int192, SCALE>
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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 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: Int384) -> Self
pub const fn from_bits(raw: Int384) -> 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) -> Int384
pub const fn to_bits(self) -> Int384
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() -> Int384
pub const fn multiplier() -> Int384
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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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.
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.
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, SCALE>
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, SCALE>
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, 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> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D115<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D115<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) -> D115<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D115<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,
) -> D115<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D115<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.
Source§impl<const SCALE: u32> D<Int384, SCALE>
impl<const SCALE: u32> D<Int384, SCALE>
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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 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: Int768) -> Self
pub const fn from_bits(raw: Int768) -> 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) -> Int768
pub const fn to_bits(self) -> Int768
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() -> Int768
pub const fn multiplier() -> Int768
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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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.
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.
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, SCALE>
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, SCALE>
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, 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> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D230<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D230<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) -> D230<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D230<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,
) -> D230<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D230<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.
Source§impl<const SCALE: u32> D<Int768, SCALE>
impl<const SCALE: u32> D<Int768, SCALE>
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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 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: Int1536) -> Self
pub const fn from_bits(raw: Int1536) -> 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) -> Int1536
pub const fn to_bits(self) -> Int1536
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() -> Int1536
pub const fn multiplier() -> Int1536
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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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.
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.
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, SCALE>
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, SCALE>
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, 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> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D462<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D462<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) -> D462<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D462<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,
) -> D462<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D462<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.
Source§impl<const SCALE: u32> D<Int1536, SCALE>
impl<const SCALE: u32> D<Int1536, SCALE>
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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 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: Int2048) -> Self
pub const fn from_bits(raw: Int2048) -> 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) -> Int2048
pub const fn to_bits(self) -> Int2048
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() -> Int2048
pub const fn multiplier() -> Int2048
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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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.
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.
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, SCALE>
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, SCALE>
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, 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> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D616<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D616<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) -> D616<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D616<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,
) -> D616<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D616<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.
Source§impl<const SCALE: u32> D<Int2048, SCALE>
impl<const SCALE: u32> D<Int2048, SCALE>
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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 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: Int3072) -> Self
pub const fn from_bits(raw: Int3072) -> 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) -> Int3072
pub const fn to_bits(self) -> Int3072
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() -> Int3072
pub const fn multiplier() -> Int3072
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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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.
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.
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, SCALE>
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, SCALE>
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, 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> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D924<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D924<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) -> D924<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D924<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,
) -> D924<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D924<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.
Source§impl<const SCALE: u32> D<Int3072, SCALE>
impl<const SCALE: u32> D<Int3072, SCALE>
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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 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: Int4096) -> Self
pub const fn from_bits(raw: Int4096) -> 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) -> Int4096
pub const fn to_bits(self) -> Int4096
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() -> Int4096
pub const fn multiplier() -> Int4096
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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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.
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.
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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. Rounded toward
zero. The numerator is pre-multiplied by 10^SCALE
in $Wider so the intermediate carries the scale-up
step without losing precision.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Wrapping division. Computes self / rhs with the
scale-up step done modulo $Wider’s range and the
final narrowing wrapping. 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
together with a boolean flag — true if the exact
quotient was out of range or rhs was zero.
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, SCALE>
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, SCALE>
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, SCALE>
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Correctly-rounded square root.
Negative inputs saturate to Self::ZERO, matching the
f64-bridge saturate-not-panic policy of the narrow tiers.
§Precision
Strict: integer-only; the result is the exact square root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode. See the
D38::sqrt_strict_with doc for the per-mode contract:
ties are impossible for an integer radicand, so the
three half-modes coincide.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which dispatches to the kernel registered for this
(width, SCALE) cell in crate::policy::sqrt.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Correctly-rounded cube root.
Defined for the whole real line: cbrt(-x) == -cbrt(x).
§Precision
Strict: integer-only; the result is the exact cube root correctly rounded to the type’s last place (within 0.5 ULP).
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. Sign is
preserved; Floor / Ceiling bump magnitude only when
the bump moves the signed result in their direction.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Square root. With strict enabled this is the
integer-only, correctly-rounded Self::sqrt_strict.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Cube root. With strict enabled this is the
integer-only, correctly-rounded Self::cbrt_strict.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
sqrt(self² + other²) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Uses the scale-trick algorithm:
hypot(a, b) = max(|a|,|b|) · sqrt(1 + (min(|a|,|b|)/max(|a|,|b|))²)The min/max ratio lies in [0, 1], so ratio² + 1 is
always in [1, 2] — the inner sqrt never overflows. The
outer multiply by large only overflows when the true
hypotenuse genuinely exceeds the type’s range.
hypot(0, 0) = 0 (bit-exact); hypot(0, x) = |x|.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner sqrt step.
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Natural logarithm (base e). Strict: integer-only and
correctly rounded. Panics if self <= 0.
Delegates to the policy-registered ln kernel for this
(width, SCALE) cell — see policy::ln.
Sourcepub fn ln_strict_agm(self) -> Self
pub fn ln_strict_agm(self) -> Self
Natural logarithm via the Brent–Salamin AGM (1976).
Strict and correctly rounded. Same contract as
Self::ln_strict; the implementation path differs.
AGM converges quadratically and scales better than the
artanh-series path at very high working scales.
Currently an alternate; the canonical ln_strict stays
on the artanh path until a bench at the relevant
working scale shows AGM winning by the
OVERRIDE_POLICY.md margin.
Sourcepub fn exp_strict_agm(self) -> Self
pub fn exp_strict_agm(self) -> Self
e^self via Newton’s iteration on ln_fixed_agm.
Strict and correctly rounded. Same contract as
Self::exp_strict; the implementation path differs.
Quadratic convergence makes this asymptotically faster
than the Taylor exp_strict at very high working
scales.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Logarithm of self in the given base, as
ln(self) / ln(base). Strict and correctly rounded.
Panics if self <= 0, base <= 0, or base == 1.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Base-2 logarithm. Strict and correctly rounded. Panics if
self <= 0.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Base-10 logarithm. Strict and correctly rounded. Panics
if self <= 0.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
e^self. Strict and correctly rounded. Panics if the
result overflows the representable range.
Delegates to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
2^self, as exp(self · ln 2). Strict and correctly
rounded. Panics if the result overflows.
Sourcepub fn powf_strict(self, exp: Self) -> Self
pub fn powf_strict(self, exp: Self) -> Self
self raised to the power exp, as exp(exp · ln self).
Strict and correctly rounded. A zero or negative base
saturates to ZERO (a negative base with a fractional
exponent is not real-valued).
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Strict and correctly rounded.
Delegates to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). Strict and correctly
rounded. The policy-registered kernel evaluates a
single sin_fixed(π/2 − self) via the cofunction
identity — no sqrt, no shared Taylor with sin.
sin_cos_strict keeps the shared-Taylor
sin_cos_fixed path for joint evaluation.
Delegates to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sin_cos_strict(self) -> (Self, Self)
pub fn sin_cos_strict(self) -> (Self, Self)
Joint sine and cosine of self (radians), returned
as (sin, cos). Strict and correctly rounded.
Internally shares one Taylor-series evaluation between
the two results (computing only |sin| and recovering
|cos| = √(1 − sin²) from the Pythagorean identity),
so the wall-clock is ~one sin_strict + one wide sqrt
— roughly half the cost of (self.sin_strict(), self.cos_strict()).
Useful for rotation matrices, polar→cartesian, complex
e^{iθ} evaluation, and anywhere both trig values of
the same argument are needed.
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent of self (radians), as sin / cos. Strict and
correctly rounded. Panics at odd multiples of π/2.
Delegates to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent of self, in radians, in (−π/2, π/2).
Strict and correctly rounded.
Delegates to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine of self, in radians, in [−π/2, π/2].
Strict. Panics if |self| > 1.
Two-range kernel to preserve the 0-ULP contract at
every representable input including the asymptotic
edge |x| → 1:
|x| ≤ 0.5: the direct identityasin(x) = atan(x / √(1 − x²)). At this range1 − x² ∈ [0.75, 1]— no cancellation in the subtraction, so the sqrt keeps full precision.0.5 < |x| < 1: the half-angle identityasin(x) = π/2 − 2·asin(√((1−|x|)/2)). The inner√((1−|x|)/2)lies in(0, 0.5]so the recursive asin call hits the stable range. The(1−|x|)/2subtraction is exact at integer level (no cancellation —|x|≤ 1 means1−|x| ≥ 0), so the asymptotic-edge precision is bounded by the working scale, not by the input’s distance from 1.
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine of self, in radians, in [0, π], as
π/2 − asin(self). Strict. Panics if |self| > 1.
Uses the same two-range asin kernel as
Self::asin_strict for the underlying asin.
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other
(x), in radians, in (−π, π]. Strict and correctly
rounded.
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine, as (eˣ − e⁻ˣ)/2. Strict and correctly
rounded.
Delegates to the policy-registered sinh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine, as (eˣ + e⁻ˣ)/2. Strict and
correctly rounded.
Delegates to the policy-registered cosh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent, as sinh / cosh. Strict and
correctly rounded. Shares one exp(v) and one
exp(−v) between the implicit sinh and cosh, then
tanh = (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) — same arithmetic as
the historic path, but the divide and the two
subtraction/addition operands are inlined here to
avoid going through the intermediate sinh/cosh.
Delegates to the policy-registered tanh kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn sinh_cosh_strict(self) -> (Self, Self)
pub fn sinh_cosh_strict(self) -> (Self, Self)
Joint hyperbolic sine and cosine of self, returned
as (sinh, cosh). Strict and correctly rounded.
One exp(v) evaluation plus the exp(-v) = 1/exp(v)
identity gives both eˣ and e⁻ˣ for sinh + cosh.
Wide-tier exp_fixed is ~10-20× the cost of a wide
divide, so the identity drops this joint kernel
roughly 40% versus running two exp_fixed calls.
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine, as
sign · ln(|x| + √(x² + 1)). Strict and correctly
rounded. For |x| ≥ 1 the radicand is factored to keep
x² inside the working width.
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine, as ln(x + √(x² − 1)),
defined for x ≥ 1. Strict and correctly rounded. For
x ≥ 2 the radicand is factored to keep x² in range.
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent, as ln((1+x)/(1−x)) / 2,
defined for |x| < 1. Strict and correctly rounded.
Panics if |self| >= 1.
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π). Strict
and correctly rounded. Panics if |self| · 180
overflows the working integer.
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180). Strict
and correctly rounded. mul is the scale-aware
(a * b) / 10^w, so the working-width budget is the
same as any other binary op in the core — no separate
overflow check needed.
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict. Delegates to
the policy-registered ln kernel for this (width, SCALE)
cell — see policy::ln.
Sourcepub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::ln_strict_agm.
Sourcepub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_agm_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict_agm.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log_strict.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log2_strict.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::log10_strict.
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp_strict. Delegates
to the policy-registered exp kernel for this
(width, SCALE) cell — see policy::exp.
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::exp2_strict.
Sourcepub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::powf_strict.
Sourcepub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sin_strict. Delegates
to the policy-registered sin kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cos_strict. Delegates
to the policy-registered cos kernel for this
(width, SCALE) cell — see policy::trig.
Note: pre-policy this method ran sin_fixed(self + π/2)
while the no-mode cos_strict ran the shared
sin_cos_fixed Pythagorean-identity path. The migration
consolidates both on the latter (faster) path; the two
paths agree to well within the existing 2-ULP test
slack.
Sourcepub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tan_strict. Delegates
to the policy-registered tan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan_strict. Delegates
to the policy-registered atan kernel for this
(width, SCALE) cell — see policy::trig.
Sourcepub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asin_strict. Same
two-range kernel; see the unmodified docs there for
the algorithm.
Sourcepub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acos_strict.
Sourcepub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atan2_strict. Same
max-branch + quadrant logic.
Sourcepub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::sinh_strict.
Uses the exp(-v) = 1/exp(v) identity to replace the
second exp_fixed call with one wide divide. Wide-tier
exp_fixed is dominated by the Tang-table reduction +
Taylor series and costs ~10-20× more than a wide
divide; the identity drops the per-call wall-clock
roughly 40%.
Sourcepub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::cosh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with; one exp_fixed plus one
divide replaces two exp_fixeds.
Sourcepub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::tanh_strict.
Same exp(-v) = 1/exp(v) identity as
Self::sinh_strict_with.
Sourcepub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::asinh_strict.
Sourcepub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::acosh_strict.
Sourcepub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::atanh_strict.
Sourcepub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_degrees_strict.
Sourcepub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
Mode-aware sibling of Self::to_radians_strict.
Sourcepub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sin_cos_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sin_cos_strict.
Sourcepub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
pub fn sinh_cosh_strict_with(self, mode: RoundingMode) -> (Self, Self)
Mode-aware sibling of Self::sinh_cosh_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural log with caller-chosen guard digits.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Log to chosen base with caller-chosen guard digits.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Log to chosen base with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Log base 2 with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 2 with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Log base 10 with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Log base 10 with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
eˣ with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
eˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
2ˣ with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
2ˣ with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
pub fn powf_approx(self, exp: Self, working_digits: u32) -> Self
xʸ with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: Self, working_digits: u32, mode: RoundingMode, ) -> Self
xʸ with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
Sine with caller-chosen guard digits.
Sourcepub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
Cosine with caller-chosen guard digits.
Sourcepub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
pub fn sin_cos_approx(self, working_digits: u32) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits.
Sourcepub fn sin_cos_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sin_cos_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sine/cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
Tangent with caller-chosen guard digits.
Sourcepub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
Arctangent with caller-chosen guard digits.
Sourcepub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
Arcsine with caller-chosen guard digits.
Sourcepub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arcsine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
Arccosine with caller-chosen guard digits.
Sourcepub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Arccosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
Four-quadrant arctangent with caller-chosen guard digits.
Sourcepub fn atan2_approx_with(
self,
other: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Four-quadrant arctangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
Hyperbolic sine with caller-chosen guard digits.
Sourcepub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
Hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
Hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
pub fn sinh_cosh_approx(self, working_digits: u32) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits.
Sourcepub fn sinh_cosh_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> (Self, Self)
pub fn sinh_cosh_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> (Self, Self)
Joint sinh/cosh with caller-chosen guard digits AND rounding mode.
Sourcepub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic sine with caller-chosen guard digits.
Sourcepub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic sine with caller-chosen guard digits AND rounding mode.
Sourcepub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits.
Sourcepub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic cosine with caller-chosen guard digits AND rounding mode.
Sourcepub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits.
Sourcepub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Inverse hyperbolic tangent with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
Radians-to-degrees with caller-chosen guard digits.
Sourcepub fn to_degrees_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Radians-to-degrees with caller-chosen guard digits AND rounding mode.
Sourcepub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
Degrees-to-radians with caller-chosen guard digits.
Sourcepub fn to_radians_approx_with(
self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Degrees-to-radians with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, SCALE>
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
With strict, dispatches to Self::ln_strict.
Sourcepub fn log(self, base: Self) -> Self
pub fn log(self, base: Self) -> Self
With strict, dispatches to Self::log_strict.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
With strict, dispatches to Self::log2_strict.
Sourcepub fn log10(self) -> Self
pub fn log10(self) -> Self
With strict, dispatches to Self::log10_strict.
Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
With strict, dispatches to Self::exp_strict.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
With strict, dispatches to Self::exp2_strict.
Sourcepub fn powf(self, exp: Self) -> Self
pub fn powf(self, exp: Self) -> Self
With strict, dispatches to Self::powf_strict.
Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
With strict, dispatches to Self::sin_strict.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
With strict, dispatches to Self::cos_strict.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
With strict, dispatches to Self::tan_strict.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
With strict, dispatches to Self::asin_strict.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
With strict, dispatches to Self::acos_strict.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
With strict, dispatches to Self::atan_strict.
Sourcepub fn atan2(self, other: Self) -> Self
pub fn atan2(self, other: Self) -> Self
With strict, dispatches to Self::atan2_strict.
Sourcepub fn sinh(self) -> Self
pub fn sinh(self) -> Self
With strict, dispatches to Self::sinh_strict.
Sourcepub fn cosh(self) -> Self
pub fn cosh(self) -> Self
With strict, dispatches to Self::cosh_strict.
Sourcepub fn tanh(self) -> Self
pub fn tanh(self) -> Self
With strict, dispatches to Self::tanh_strict.
Sourcepub fn asinh(self) -> Self
pub fn asinh(self) -> Self
With strict, dispatches to Self::asinh_strict.
Sourcepub fn acosh(self) -> Self
pub fn acosh(self) -> Self
With strict, dispatches to Self::acosh_strict.
Sourcepub fn atanh(self) -> Self
pub fn atanh(self) -> Self
With strict, dispatches to Self::atanh_strict.
Sourcepub fn to_degrees(self) -> Self
pub fn to_degrees(self) -> Self
With strict, dispatches to Self::to_degrees_strict.
Sourcepub fn to_radians(self) -> Self
pub fn to_radians(self) -> Self
With strict, dispatches to Self::to_radians_strict.
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, SCALE>
Sourcepub fn from_int(value: i128) -> Self
pub fn from_int(value: i128) -> Self
Constructs from an integer source, scaling by 10^SCALE.
Overflow follows the wide integer’s default arithmetic semantics.
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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, 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> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, SCALE>
Sourcepub fn rescale<const TARGET_SCALE: u32>(self) -> D1232<TARGET_SCALE>
pub fn rescale<const TARGET_SCALE: u32>(self) -> D1232<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) -> D1232<TARGET_SCALE>
pub fn with_scale<const TARGET_SCALE: u32>(self) -> D1232<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,
) -> D1232<TARGET_SCALE>
pub fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D1232<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.
Source§impl<const SCALE: u32> D<Int4096, SCALE>
impl<const SCALE: u32> D<Int4096, SCALE>
Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, 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 divide by 10^SCALE according to mode.
The default Mul operator delegates to this with the
crate-default rounding mode; call mul_with directly when
you need a non-default rounding rule (e.g.
HalfAwayFromZero for commercial rounding, Floor/Ceiling
for one-sided bracketing).
§Panics
Panics in debug builds when the rescaled quotient overflows
i128. Wraps two’s-complement in release builds.
§Precision
Strict: integer-only arithmetic. Within 0.5 ULP for the half-* family; directed rounding otherwise.
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 final
divide step according to mode.
The default Div operator delegates to this with the
crate-default rounding mode.
§Panics
Panics on division by zero (matching i128 /). Panics in debug
builds when the quotient overflows i128; wraps in release.
§Precision
Strict: integer-only arithmetic. Within 0.5 ULP for the half-* family; directed rounding otherwise.
Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub fn checked_mul(self, rhs: Self) -> Option<Self>
pub fn checked_mul(self, rhs: Self) -> Option<Self>
Returns self * rhs, or None if the rescaled product does not
fit in i128.
The intermediate product is computed with 256-bit arithmetic and
cannot itself overflow. The only failure mode is a final i128
quotient that exceeds the storage range.
§Precision
Strict: the result is truncated (not rounded) toward zero during
the scale-restoring divide, identical to the default * operator.
§Examples
use decimal_scaled::D38s12;
let half = D38s12::from_bits(500_000_000_000); // 0.5
assert_eq!(half.checked_mul(half), Some(D38s12::from_bits(250_000_000_000)));
assert_eq!(D38s12::MAX.checked_mul(D38s12::from_bits(2_000_000_000_000)), None);Sourcepub fn wrapping_mul(self, rhs: Self) -> Self
pub fn wrapping_mul(self, rhs: Self) -> Self
Returns self * rhs with two’s-complement wrap when the rescaled
product does not fit in i128.
On overflow, falls back to (a.wrapping_mul(b)).wrapping_div(multiplier()).
The exact bit pattern of the wrapping result at extreme magnitudes
is an implementation detail; only the no-panic contract is guaranteed.
§Precision
Strict: truncates toward zero during the scale-restoring divide.
§Examples
use decimal_scaled::D38s12;
let half = D38s12::from_bits(500_000_000_000); // 0.5
assert_eq!(half.wrapping_mul(half), D38s12::from_bits(250_000_000_000));
// Overflow does not panic.
let _ = D38s12::MAX.wrapping_mul(D38s12::from_bits(2_000_000_000_000));Sourcepub fn saturating_mul(self, rhs: Self) -> Self
pub fn saturating_mul(self, rhs: Self) -> Self
Returns self * rhs, clamped to D38::MAX or D38::MIN on overflow.
The clamp direction is determined by the XOR of operand signs:
same-sign operands saturate to MAX; mixed-sign operands saturate
to MIN.
§Precision
Strict: truncates toward zero during the scale-restoring divide.
§Examples
use decimal_scaled::D38s12;
let two = D38s12::from_bits(2_000_000_000_000); // 2.0
assert_eq!(D38s12::MAX.saturating_mul(two), D38s12::MAX);
assert_eq!(D38s12::MAX.saturating_mul(-two), D38s12::MIN);Sourcepub fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub fn overflowing_mul(self, rhs: Self) -> (Self, bool)
Returns (self * rhs, did_overflow) where the value is the
wrapping result when overflow occurs.
§Precision
Strict: truncates toward zero during the scale-restoring divide.
§Examples
use decimal_scaled::D38s12;
let half = D38s12::from_bits(500_000_000_000); // 0.5
assert_eq!(half.overflowing_mul(half), (D38s12::from_bits(250_000_000_000), false));
let (_, ovf) = D38s12::MAX.overflowing_mul(D38s12::from_bits(2_000_000_000_000));
assert!(ovf);Sourcepub fn checked_div(self, rhs: Self) -> Option<Self>
pub fn checked_div(self, rhs: Self) -> Option<Self>
Returns self / rhs, or None on division by zero or if the
rescaled quotient does not fit in i128.
The only finite-operand overflow case is
D38::MIN / NEG_ONE (storage negation of i128::MIN overflows).
§Precision
Strict: the widening divide truncates toward zero, identical to
the default / operator.
§Examples
use decimal_scaled::D38s12;
let six = D38s12::from_bits(6_000_000_000_000); // 6.0
let two = D38s12::from_bits(2_000_000_000_000); // 2.0
assert_eq!(six.checked_div(two), Some(D38s12::from_bits(3_000_000_000_000)));
assert_eq!(D38s12::ONE.checked_div(D38s12::ZERO), None);Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Returns self / rhs with two’s-complement wrap when the rescaled
quotient does not fit in i128.
On overflow, falls back to
(a.wrapping_mul(multiplier())).wrapping_div(b).
§Precision
Strict: truncates toward zero.
§Panics
Panics on rhs == ZERO (matches i128::wrapping_div).
§Examples
use decimal_scaled::D38s12;
let six = D38s12::from_bits(6_000_000_000_000); // 6.0
let two = D38s12::from_bits(2_000_000_000_000); // 2.0
assert_eq!(six.wrapping_div(two), D38s12::from_bits(3_000_000_000_000));Sourcepub fn saturating_div(self, rhs: Self) -> Self
pub fn saturating_div(self, rhs: Self) -> Self
Returns self / rhs, clamped to D38::MAX or D38::MIN on
overflow.
The clamp direction is determined by the XOR of operand signs, because the scale multiplier is always positive.
§Precision
Strict: truncates toward zero.
§Panics
Panics on rhs == ZERO (matches i128::saturating_div).
§Examples
use decimal_scaled::D38s12;
let six = D38s12::from_bits(6_000_000_000_000); // 6.0
let two = D38s12::from_bits(2_000_000_000_000); // 2.0
assert_eq!(six.saturating_div(two), D38s12::from_bits(3_000_000_000_000));
// MAX / 0.5 overflows; both positive so clamp to MAX.
assert_eq!(D38s12::MAX.saturating_div(D38s12::from_bits(500_000_000_000)), D38s12::MAX);Sourcepub fn overflowing_div(self, rhs: Self) -> (Self, bool)
pub fn overflowing_div(self, rhs: Self) -> (Self, bool)
Returns (self / rhs, did_overflow) where the value is the
wrapping result when overflow occurs.
§Precision
Strict: truncates toward zero.
§Panics
Panics on rhs == ZERO (matches i128::overflowing_div).
§Examples
use decimal_scaled::D38s12;
let six = D38s12::from_bits(6_000_000_000_000); // 6.0
let two = D38s12::from_bits(2_000_000_000_000); // 2.0
assert_eq!(six.overflowing_div(two), (D38s12::from_bits(3_000_000_000_000), false));
let half = D38s12::from_bits(500_000_000_000); // 0.5
let (_, ovf) = D38s12::MAX.overflowing_div(half);
assert!(ovf);Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub const fn rescale<const TARGET_SCALE: u32>(self) -> D38<TARGET_SCALE>
pub const 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; see that method for
scale-up / scale-down semantics and the overflow policy.
Sourcepub const fn with_scale<const TARGET_SCALE: u32>(self) -> D38<TARGET_SCALE>
pub const 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 const fn rescale_with<const TARGET_SCALE: u32>(
self,
mode: RoundingMode,
) -> D38<TARGET_SCALE>
pub const 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.
Source§impl<const SCALE: u32> D<i64, SCALE>
impl<const SCALE: u32> D<i64, SCALE>
Sourcepub const fn rescale<const TARGET_SCALE: u32>(self) -> D18<TARGET_SCALE>
pub const fn rescale<const TARGET_SCALE: u32>(self) -> D18<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) -> D18<TARGET_SCALE>
pub const fn with_scale<const TARGET_SCALE: u32>(self) -> D18<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,
) -> D18<TARGET_SCALE>
pub const fn rescale_with<const TARGET_SCALE: u32>( self, mode: RoundingMode, ) -> D18<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.
Source§impl<const SCALE: u32> D<i32, SCALE>
impl<const SCALE: u32> D<i32, 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.
Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub fn ln_strict(self) -> Self
pub fn ln_strict(self) -> Self
Returns the natural logarithm (base e) of self.
§Algorithm
Range reduction x = 2^k * m with m ∈ [1, 2), then the
area-hyperbolic-tangent series
ln(m) = 2·artanh(t), t = (m-1)/(m+1) ∈ [0, 1/3],
artanh(t) = t + t³/3 + t⁵/5 + …, evaluated in a 256-bit
fixed-point intermediate at SCALE + STRICT_GUARD working
digits. The guard digits bound the total accumulated rounding
error far below 0.5 ULP of the output, so the result —
k·ln(2) + ln(m), rounded once at the end — is correctly
rounded.
§Precision
Strict: integer-only, and correctly rounded — the result is within 0.5 ULP of the exact natural logarithm.
§Panics
Panics if self <= 0, or if the result overflows the type’s
representable range (only possible for ln of a near-MAX
value at SCALE >= 37).
Sourcepub fn ln_strict_with(self, mode: RoundingMode) -> Self
pub fn ln_strict_with(self, mode: RoundingMode) -> Self
Natural log under the supplied rounding mode. See Self::ln_strict.
Sourcepub fn ln_approx(self, working_digits: u32) -> Self
pub fn ln_approx(self, working_digits: u32) -> Self
Natural logarithm with a caller-chosen number of guard digits above the storage scale, trading away the strict 0.5-ULP guarantee for proportionally faster evaluation.
Sourcepub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn ln_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Natural log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log_strict(self, base: Self) -> Self
pub fn log_strict(self, base: Self) -> Self
Returns the logarithm of self in the given base.
Sourcepub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
pub fn log_strict_with(self, base: Self, mode: RoundingMode) -> Self
Logarithm in base under the supplied rounding mode.
Sourcepub fn log_approx(self, base: Self, working_digits: u32) -> Self
pub fn log_approx(self, base: Self, working_digits: u32) -> Self
Logarithm with caller-chosen guard digits. See ln_approx.
Sourcepub fn log_approx_with(
self,
base: Self,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn log_approx_with( self, base: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Logarithm with caller-chosen guard digits AND rounding mode.
Sourcepub fn log2_strict(self) -> Self
pub fn log2_strict(self) -> Self
Returns the base-2 logarithm of self.
Sourcepub fn log2_strict_with(self, mode: RoundingMode) -> Self
pub fn log2_strict_with(self, mode: RoundingMode) -> Self
Base-2 log under the supplied rounding mode.
Sourcepub fn log2_approx(self, working_digits: u32) -> Self
pub fn log2_approx(self, working_digits: u32) -> Self
Base-2 log with caller-chosen guard digits.
Sourcepub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Base-2 log with caller-chosen guard digits AND rounding mode.
Sourcepub fn log10_strict(self) -> Self
pub fn log10_strict(self) -> Self
Returns the base-10 logarithm of self.
Sourcepub fn log10_strict_with(self, mode: RoundingMode) -> Self
pub fn log10_strict_with(self, mode: RoundingMode) -> Self
Base-10 log under the supplied rounding mode.
Sourcepub fn log10_approx(self, working_digits: u32) -> Self
pub fn log10_approx(self, working_digits: u32) -> Self
Base-10 log with caller-chosen guard digits.
Sourcepub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn log10_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Base-10 log with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp_strict(self) -> Self
pub fn exp_strict(self) -> Self
Returns e^self (natural exponential).
Sourcepub fn exp_strict_with(self, mode: RoundingMode) -> Self
pub fn exp_strict_with(self, mode: RoundingMode) -> Self
e^self under the supplied rounding mode.
Sourcepub fn exp_approx(self, working_digits: u32) -> Self
pub fn exp_approx(self, working_digits: u32) -> Self
Exponential with caller-chosen guard digits.
Sourcepub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Exponential with caller-chosen guard digits AND rounding mode.
Sourcepub fn exp2_strict(self) -> Self
pub fn exp2_strict(self) -> Self
Returns 2^self (base-2 exponential).
Sourcepub fn exp2_strict_with(self, mode: RoundingMode) -> Self
pub fn exp2_strict_with(self, mode: RoundingMode) -> Self
2^self under the supplied rounding mode.
Sourcepub fn exp2_approx(self, working_digits: u32) -> Self
pub fn exp2_approx(self, working_digits: u32) -> Self
Base-2 exponential with caller-chosen guard digits.
Sourcepub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
pub fn exp2_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Base-2 exponential with caller-chosen guard digits AND rounding mode.
Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
pub fn sin(self) -> Self
pub fn cos(self) -> Self
pub fn tan(self) -> Self
pub fn asin(self) -> Self
pub fn acos(self) -> Self
pub fn atan(self) -> Self
pub fn atan2(self, other: Self) -> Self
pub fn sinh(self) -> Self
pub fn cosh(self) -> Self
pub fn tanh(self) -> Self
pub fn asinh(self) -> Self
pub fn acosh(self) -> Self
pub fn atanh(self) -> Self
pub fn to_degrees(self) -> Self
pub fn to_radians(self) -> Self
Sourcepub fn sin_strict(self) -> Self
pub fn sin_strict(self) -> Self
Sine of self (radians). Correctly rounded.
pub fn sin_strict_with(self, mode: RoundingMode) -> Self
pub fn sin_approx(self, working_digits: u32) -> Self
pub fn sin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn cos_strict(self) -> Self
pub fn cos_strict(self) -> Self
Cosine of self (radians). cos(x) = sin(x + π/2).
pub fn cos_strict_with(self, mode: RoundingMode) -> Self
pub fn cos_approx(self, working_digits: u32) -> Self
pub fn cos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn tan_strict(self) -> Self
pub fn tan_strict(self) -> Self
Tangent. Panics if cos(self) is zero.
pub fn tan_strict_with(self, mode: RoundingMode) -> Self
pub fn tan_approx(self, working_digits: u32) -> Self
pub fn tan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn atan_strict(self) -> Self
pub fn atan_strict(self) -> Self
Arctangent.
pub fn atan_strict_with(self, mode: RoundingMode) -> Self
pub fn atan_approx(self, working_digits: u32) -> Self
pub fn atan_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn asin_strict(self) -> Self
pub fn asin_strict(self) -> Self
Arcsine. Panics if |self| > 1.
pub fn asin_strict_with(self, mode: RoundingMode) -> Self
pub fn asin_approx(self, working_digits: u32) -> Self
pub fn asin_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn acos_strict(self) -> Self
pub fn acos_strict(self) -> Self
Arccosine. Panics if |self| > 1.
pub fn acos_strict_with(self, mode: RoundingMode) -> Self
pub fn acos_approx(self, working_digits: u32) -> Self
pub fn acos_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn atan2_strict(self, other: Self) -> Self
pub fn atan2_strict(self, other: Self) -> Self
Four-quadrant arctangent of self (y) and other (x).
pub fn atan2_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn atan2_approx(self, other: Self, working_digits: u32) -> Self
pub fn atan2_approx_with( self, other: Self, working_digits: u32, mode: RoundingMode, ) -> Self
Sourcepub fn sinh_strict(self) -> Self
pub fn sinh_strict(self) -> Self
Hyperbolic sine. Correctly rounded.
pub fn sinh_strict_with(self, mode: RoundingMode) -> Self
pub fn sinh_approx(self, working_digits: u32) -> Self
pub fn sinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn cosh_strict(self) -> Self
pub fn cosh_strict(self) -> Self
Hyperbolic cosine.
pub fn cosh_strict_with(self, mode: RoundingMode) -> Self
pub fn cosh_approx(self, working_digits: u32) -> Self
pub fn cosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn tanh_strict(self) -> Self
pub fn tanh_strict(self) -> Self
Hyperbolic tangent.
pub fn tanh_strict_with(self, mode: RoundingMode) -> Self
pub fn tanh_approx(self, working_digits: u32) -> Self
pub fn tanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn asinh_strict(self) -> Self
pub fn asinh_strict(self) -> Self
Inverse hyperbolic sine. asinh(x) = sign · ln(|x| + √(x²+1)).
pub fn asinh_strict_with(self, mode: RoundingMode) -> Self
pub fn asinh_approx(self, working_digits: u32) -> Self
pub fn asinh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn acosh_strict(self) -> Self
pub fn acosh_strict(self) -> Self
Inverse hyperbolic cosine. Panics if self < 1.
pub fn acosh_strict_with(self, mode: RoundingMode) -> Self
pub fn acosh_approx(self, working_digits: u32) -> Self
pub fn acosh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn atanh_strict(self) -> Self
pub fn atanh_strict(self) -> Self
Inverse hyperbolic tangent. Panics if |self| >= 1.
pub fn atanh_strict_with(self, mode: RoundingMode) -> Self
pub fn atanh_approx(self, working_digits: u32) -> Self
pub fn atanh_approx_with(self, working_digits: u32, mode: RoundingMode) -> Self
Sourcepub fn to_degrees_strict(self) -> Self
pub fn to_degrees_strict(self) -> Self
Convert radians to degrees: self · (180 / π).
pub fn to_degrees_strict_with(self, mode: RoundingMode) -> Self
pub fn to_degrees_approx(self, working_digits: u32) -> Self
pub fn to_degrees_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Sourcepub fn to_radians_strict(self) -> Self
pub fn to_radians_strict(self) -> Self
Convert degrees to radians: self · (π / 180).
pub fn to_radians_strict_with(self, mode: RoundingMode) -> Self
pub fn to_radians_approx(self, working_digits: u32) -> Self
pub fn to_radians_approx_with( self, working_digits: u32, mode: RoundingMode, ) -> Self
Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub fn pow(self, exp: u32) -> Self
pub fn pow(self, exp: u32) -> Self
Raises self to the power exp.
Uses square-and-multiply: walks the bits of exp from low to
high, squaring the base each step and accumulating when the
corresponding bit is set. Costs O(log exp) multiplications.
Each multiplication routes through the D38 Mul operator.
exp = 0 always returns ONE, even when self is ZERO
(matches i128::pow convention).
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Panics
In debug builds, panics on i128 overflow at any multiplication
step. In release builds, wraps two’s-complement. Matches
i128::pow and D38::Mul semantics.
Use Self::checked_pow, Self::wrapping_pow,
Self::saturating_pow, or Self::overflowing_pow for
explicit overflow control.
§Examples
use decimal_scaled::D38s12;
let two = D38s12::from_int(2);
assert_eq!(two.pow(10), D38s12::from_int(1024));
// exp = 0 returns ONE regardless of base.
assert_eq!(D38s12::ZERO.pow(0), D38s12::ONE);Sourcepub fn powi(self, exp: i32) -> Self
pub fn powi(self, exp: i32) -> Self
Raises self to the signed integer power exp.
For non-negative exp, equivalent to self.pow(exp as u32).
For negative exp, returns D38::ONE / self.pow(exp.unsigned_abs()),
i.e. the reciprocal of the positive-exponent form.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Panics
- Overflow of
i128storage at any step in debug builds (matchesSelf::pow). - Division by zero when
self == ZEROandexp < 0.
§Examples
use decimal_scaled::D38s12;
let two = D38s12::from_int(2);
assert_eq!(two.powi(-1), D38s12::ONE / two);
assert_eq!(two.powi(0), D38s12::ONE);
assert_eq!(two.powi(3), D38s12::from_int(8));Sourcepub fn powf_strict(self, exp: D38<SCALE>) -> Self
pub fn powf_strict(self, exp: D38<SCALE>) -> Self
Raises self to the power exp (strict integer-only stub).
Converts both operands to f64, calls f64::powf, then converts
the result back. For integer exponents, prefer Self::pow or
Self::powi, which are bit-exact.
NaN results map to ZERO; infinities clamp to MAX or MIN,
following the saturate-vs-error policy of Self::from_f64.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Examples
use decimal_scaled::D38s12;
let two = D38s12::from_int(2);
let three = D38s12::from_int(3);
// 2^3 = 8, within f64 precision.
assert!((two.powf(three).to_f64() - 8.0).abs() < 1e-9);Raises self to the power exp, computed integer-only as
exp(exp · ln(self)) — the ln, the · exp, and the exp all
run in the shared wide guard-digit intermediate, so the result
is correctly rounded (within 0.5 ULP).
Always available, regardless of the strict feature. When
strict is enabled, the plain Self::powf delegates here.
A zero or negative base saturates to ZERO (a negative base
with an arbitrary fractional exponent is not real-valued),
matching the f64-bridge NaN-to-ZERO policy.
Sourcepub fn powf_strict_with(self, exp: D38<SCALE>, mode: RoundingMode) -> Self
pub fn powf_strict_with(self, exp: D38<SCALE>, mode: RoundingMode) -> Self
self^exp under the supplied rounding mode.
Sourcepub fn powf_approx(self, exp: D38<SCALE>, working_digits: u32) -> Self
pub fn powf_approx(self, exp: D38<SCALE>, working_digits: u32) -> Self
self^exp with caller-chosen guard digits.
Sourcepub fn powf_approx_with(
self,
exp: D38<SCALE>,
working_digits: u32,
mode: RoundingMode,
) -> Self
pub fn powf_approx_with( self, exp: D38<SCALE>, working_digits: u32, mode: RoundingMode, ) -> Self
self^exp with caller-chosen guard digits AND rounding mode.
Sourcepub fn powf(self, exp: D38<SCALE>) -> Self
pub fn powf(self, exp: D38<SCALE>) -> Self
Raises self to the power exp.
With the strict feature enabled this is the integer-only
Self::powf_strict; without it, the f64-bridge form.
Sourcepub fn sqrt_strict(self) -> Self
pub fn sqrt_strict(self) -> Self
Returns the square root of self (strict integer-only stub).
IEEE 754 mandates that f64::sqrt is correctly-rounded
(round-to-nearest, ties-to-even). Combined with the deterministic
to_f64 / from_f64 round-trip, this makes
D38::sqrt bit-deterministic: the same input produces the same
output bit-pattern on every IEEE-754-conformant platform.
Negative inputs produce a NaN from f64::sqrt, which
Self::from_f64 maps to ZERO per the saturate-vs-error
policy. No panic is raised for negative inputs.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Examples
use decimal_scaled::D38s12;
assert_eq!(D38s12::ZERO.sqrt(), D38s12::ZERO);
// f64::sqrt(1.0) == 1.0 exactly, so the result is bit-exact.
assert_eq!(D38s12::ONE.sqrt(), D38s12::ONE);Sourcepub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
pub fn sqrt_strict_with(self, mode: RoundingMode) -> Self
Square root under the supplied rounding mode.
Negative inputs saturate to Self::ZERO regardless of mode,
matching the f64-bridge policy.
Body delegates to policy::sqrt::SqrtPolicy::sqrt_impl,
which for D38 selects the mg_divide_d38 width-override kernel.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Returns the square root of self.
With the strict feature enabled this is the integer-only,
correctly-rounded Self::sqrt_strict; without it, the
f64-bridge form.
Sourcepub fn cbrt(self) -> Self
pub fn cbrt(self) -> Self
Returns the cube root of self.
With the strict feature enabled this is the integer-only
Self::cbrt_strict; without it, the f64-bridge form.
Sourcepub fn cbrt_strict(self) -> Self
pub fn cbrt_strict(self) -> Self
Cube root of self. Defined for all reals — the sign of the
input is preserved (cbrt(-8) = -2).
§Algorithm
For a D38<SCALE> with raw storage r, the raw storage of the
cube root is
round( cbrt(r / 10^SCALE) · 10^SCALE ) = round( cbrt(r · 10^(2·SCALE)) ).
r · 10^(2·SCALE) is formed exactly as a 384-bit value and its
integer cube root is computed exactly, so the result is the
exact cube root correctly rounded to the type’s last place
(within 0.5 ULP — the IEEE-754 round-to-nearest result).
§Precision
Strict: integer-only; correctly rounded.
Sourcepub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
pub fn cbrt_strict_with(self, mode: RoundingMode) -> Self
Cube root under the supplied rounding mode. The sign of the
input is preserved; Floor / Ceiling resolve direction
relative to the signed result.
Body delegates to policy::cbrt::CbrtPolicy::cbrt_impl.
Sourcepub fn hypot_strict(self, other: Self) -> Self
pub fn hypot_strict(self, other: Self) -> Self
Returns sqrt(self^2 + other^2) without intermediate overflow,
computed integer-only via the correctly-rounded
Self::sqrt_strict. Same scale-trick algorithm as the
f64-bridge Self::hypot; available in no_std.
Always available, regardless of the strict feature.
Sourcepub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
pub fn hypot_strict_with(self, other: Self, mode: RoundingMode) -> Self
Hypot under the supplied rounding mode. The mode applies to the inner square root; the surrounding adds and multiplies are exact-or-truncating per the operator path’s own contract.
Sourcepub fn hypot(self, other: Self) -> Self
pub fn hypot(self, other: Self) -> Self
Returns sqrt(self^2 + other^2) without intermediate overflow.
With the strict feature enabled this is the integer-only
Self::hypot_strict; without it, the f64-bridge form.
Sourcepub fn checked_pow(self, exp: u32) -> Option<Self>
pub fn checked_pow(self, exp: u32) -> Option<Self>
Returns Some(self^exp), or None if any multiplication step
overflows i128.
Walks the same square-and-multiply as Self::pow but uses
mul_div_pow10 (which returns Option<i128>) at each step.
The first None short-circuits to a None return.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Examples
use decimal_scaled::D38s12;
// MAX^2 overflows.
assert!(D38s12::MAX.checked_pow(2).is_none());
// Any power of ONE is ONE.
assert_eq!(D38s12::ONE.checked_pow(1_000_000), Some(D38s12::ONE));Sourcepub fn wrapping_pow(self, exp: u32) -> Self
pub fn wrapping_pow(self, exp: u32) -> Self
Returns self^exp, wrapping two’s-complement on overflow at
every multiplication step.
Follows the same square-and-multiply structure as Self::pow.
When a step overflows mul_div_pow10, the fallback is
wrapping_mul followed by wrapping_div of the scale
multiplier. The exact wrap pattern is deterministic and
reproducible but is not otherwise specified.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Examples
use decimal_scaled::D38s12;
// ONE^N never overflows and returns ONE.
assert_eq!(D38s12::ONE.wrapping_pow(1_000_000), D38s12::ONE);
// MAX^2 wraps to a deterministic but unspecified value.
let _ = D38s12::MAX.wrapping_pow(2);Sourcepub fn saturating_pow(self, exp: u32) -> Self
pub fn saturating_pow(self, exp: u32) -> Self
Returns self^exp, clamping to D38::MAX or D38::MIN on
overflow at any step.
On the first step that overflows, the result is clamped based on
the sign of the mathematical result: positive overflows clamp to
MAX, negative overflows clamp to MIN. The sign of the result
is determined by self.signum() and whether exp is odd.
exp = 0 always returns ONE before entering the loop.
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Examples
use decimal_scaled::D38s12;
assert_eq!(D38s12::MAX.saturating_pow(2), D38s12::MAX);
assert_eq!(D38s12::ONE.saturating_pow(1_000_000), D38s12::ONE);Sourcepub fn overflowing_pow(self, exp: u32) -> (Self, bool)
pub fn overflowing_pow(self, exp: u32) -> (Self, bool)
Returns (self^exp, overflowed).
overflowed is true if any multiplication step overflowed
i128. The returned value is the wrapping form (matches
Self::wrapping_pow).
§Precision
Strict: all arithmetic is integer-only; result is bit-exact.
§Examples
use decimal_scaled::D38s12;
let (_value, overflowed) = D38s12::MAX.overflowing_pow(2);
assert!(overflowed);
let (value, overflowed) = D38s12::ONE.overflowing_pow(5);
assert!(!overflowed);
assert_eq!(value, D38s12::ONE);Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub fn ln_fast(self) -> Self
pub fn ln_fast(self) -> Self
Returns the natural logarithm (base e) of self.
§Precision
Lossy: converts to f64, calls f64::ln, converts back. f64::ln
returns -Infinity for 0.0 (saturates to D38::MIN) and NaN
for negative inputs (maps to D38::ZERO).
§Examples
use decimal_scaled::D38s12;
// ln(1) == 0 (f64::ln(1.0) == 0.0 exactly).
assert_eq!(D38s12::ONE.ln(), D38s12::ZERO);Sourcepub fn log_fast(self, base: Self) -> Self
pub fn log_fast(self, base: Self) -> Self
Returns the logarithm of self in the given base.
Implemented via a single f64::log(self_f64, base_f64) call, which
avoids the extra quantisation that would come from computing
ln(self) / ln(base) with two separate f64 round-trips.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// log_2(8) is approximately 3 within f64 precision.
let eight = D38s12::from_int(8);
let two = D38s12::from_int(2);
let result = eight.log(two);Sourcepub fn log2_fast(self) -> Self
pub fn log2_fast(self) -> Self
Returns the base-2 logarithm of self.
§Precision
Lossy: involves f64 at some point; result may lose precision.
On IEEE-754 platforms, f64::log2 is exact for integer powers
of two (e.g. log2(8.0) == 3.0). Out-of-domain inputs follow
the same saturation policy as Self::ln.
§Examples
use decimal_scaled::D38s12;
// log2(1) == 0 (f64::log2(1.0) == 0.0 exactly).
assert_eq!(D38s12::ONE.log2(), D38s12::ZERO);Sourcepub fn log10_fast(self) -> Self
pub fn log10_fast(self) -> Self
Returns the base-10 logarithm of self.
§Precision
Lossy: involves f64 at some point; result may lose precision.
Out-of-domain inputs follow the same saturation policy as Self::ln.
§Examples
use decimal_scaled::D38s12;
// log10(1) == 0 (f64::log10(1.0) == 0.0 exactly).
assert_eq!(D38s12::ONE.log10(), D38s12::ZERO);Sourcepub fn exp_fast(self) -> Self
pub fn exp_fast(self) -> Self
Returns e^self (natural exponential).
§Precision
Lossy: involves f64 at some point; result may lose precision.
Large positive inputs overflow f64 to +Infinity, which saturates
to D38::MAX. Large negative inputs underflow to 0.0 in f64,
which maps to D38::ZERO.
§Examples
use decimal_scaled::D38s12;
// exp(0) == 1 (f64::exp(0.0) == 1.0 exactly).
assert_eq!(D38s12::ZERO.exp(), D38s12::ONE);Sourcepub fn exp2_fast(self) -> Self
pub fn exp2_fast(self) -> Self
Returns 2^self (base-2 exponential).
§Precision
Lossy: involves f64 at some point; result may lose precision.
Saturation behaviour is analogous to Self::exp but at different
magnitudes (inputs beyond approximately 1024 overflow to +Infinity).
§Examples
use decimal_scaled::D38s12;
// exp2(0) == 1 (f64::exp2(0.0) == 1.0 exactly).
assert_eq!(D38s12::ZERO.exp2(), D38s12::ONE);Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub fn tan_fast(self) -> Self
pub fn tan_fast(self) -> Self
Tangent of self, where self is in radians.
f64::tan returns very large magnitudes near odd multiples of
pi/2 and infinity at the limit. Inputs that drive the f64
result outside [D38::MIN, D38::MAX] saturate per
Self::from_f64.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// tan(0) == 0 (bit-exact: f64::tan(0.0) == 0.0).
assert_eq!(D38s12::ZERO.tan(), D38s12::ZERO);Sourcepub fn asin_fast(self) -> Self
pub fn asin_fast(self) -> Self
Arcsine of self. Returns radians in [-pi/2, pi/2].
f64::asin returns NaN for inputs outside [-1, 1], which
Self::from_f64 maps to D38::ZERO.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// asin(0) == 0.
assert_eq!(D38s12::ZERO.asin(), D38s12::ZERO);Sourcepub fn acos_fast(self) -> Self
pub fn acos_fast(self) -> Self
Arccosine of self. Returns radians in [0, pi].
f64::acos returns NaN for inputs outside [-1, 1], which
Self::from_f64 maps to D38::ZERO.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::{D38s12, DecimalConstants};
// acos(1) == 0.
assert_eq!(D38s12::ONE.acos(), D38s12::ZERO);Sourcepub fn atan2_fast(self, other: Self) -> Self
pub fn atan2_fast(self, other: Self) -> Self
Four-quadrant arctangent of self (y) over other (x).
Returns radians in (-pi, pi].
Signature matches f64::atan2(self, other): the receiver is
y and the argument is x.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::{D38s12, DecimalConstants};
// atan2(1, 1) ~= pi/4 (45 degrees, first quadrant).
let one = D38s12::ONE;
let result = one.atan2(one); // approximately D38s12::quarter_pi()Sourcepub fn sinh_fast(self) -> Self
pub fn sinh_fast(self) -> Self
Hyperbolic sine of self.
Defined for the entire real line. Saturates at large magnitudes
per Self::from_f64.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// sinh(0) == 0.
assert_eq!(D38s12::ZERO.sinh(), D38s12::ZERO);Sourcepub fn cosh_fast(self) -> Self
pub fn cosh_fast(self) -> Self
Hyperbolic cosine of self.
Defined for the entire real line; result is always >= 1.
Saturates at large magnitudes per Self::from_f64.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// cosh(0) == 1.
assert_eq!(D38s12::ZERO.cosh(), D38s12::ONE);Sourcepub fn asinh_fast(self) -> Self
pub fn asinh_fast(self) -> Self
Sourcepub fn acosh_fast(self) -> Self
pub fn acosh_fast(self) -> Self
Inverse hyperbolic cosine of self.
f64::acosh returns NaN for inputs less than 1, which
Self::from_f64 maps to D38::ZERO.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// acosh(1) == 0.
assert_eq!(D38s12::ONE.acosh(), D38s12::ZERO);Sourcepub fn atanh_fast(self) -> Self
pub fn atanh_fast(self) -> Self
Inverse hyperbolic tangent of self.
f64::atanh returns NaN for inputs outside (-1, 1), which
Self::from_f64 maps to D38::ZERO.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// atanh(0) == 0.
assert_eq!(D38s12::ZERO.atanh(), D38s12::ZERO);Sourcepub fn to_degrees_fast(self) -> Self
pub fn to_degrees_fast(self) -> Self
Convert radians to degrees: self * (180 / pi).
Routed through f64::to_degrees so results match the de facto
reference produced by the rest of the Rust ecosystem. Multiplying
by a precomputed D38 factor derived from D38::pi() would
diverge from f64 by a 1-LSB rescale rounding without any
practical determinism gain, since the f64 bridge is already the
precision floor.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// to_degrees(0) == 0.
assert_eq!(D38s12::ZERO.to_degrees(), D38s12::ZERO);Sourcepub fn to_radians_fast(self) -> Self
pub fn to_radians_fast(self) -> Self
Convert degrees to radians: self * (pi / 180).
Routed through f64::to_radians. See Self::to_degrees for
the rationale.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
// to_radians(0) == 0.
assert_eq!(D38s12::ZERO.to_radians(), D38s12::ZERO);Source§impl<const SCALE: u32> D<i128, SCALE>
impl<const SCALE: u32> D<i128, SCALE>
Sourcepub fn powf_fast(self, exp: D38<SCALE>) -> Self
pub fn powf_fast(self, exp: D38<SCALE>) -> Self
Raises self to the power exp via the f64 bridge.
Converts both operands to f64, calls f64::powf, then converts
the result back. For integer exponents, prefer Self::pow or
Self::powi, which are bit-exact.
NaN results map to ZERO; infinities clamp to MAX or MIN,
following the saturate-vs-error policy of Self::from_f64.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
let two = D38s12::from_int(2);
let three = D38s12::from_int(3);
// 2^3 = 8, within f64 precision.
assert!((two.powf(three).to_f64() - 8.0).abs() < 1e-9);Sourcepub fn sqrt_fast(self) -> Self
pub fn sqrt_fast(self) -> Self
Returns the square root of self via the f64 bridge.
IEEE 754 mandates that f64::sqrt is correctly-rounded
(round-to-nearest, ties-to-even). Combined with the deterministic
to_f64 / from_f64 round-trip, this makes
D38::sqrt bit-deterministic: the same input produces the same
output bit-pattern on every IEEE-754-conformant platform.
Negative inputs produce a NaN from f64::sqrt, which
Self::from_f64 maps to ZERO per the saturate-vs-error
policy. No panic is raised for negative inputs.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
assert_eq!(D38s12::ZERO.sqrt(), D38s12::ZERO);
// f64::sqrt(1.0) == 1.0 exactly, so the result is bit-exact.
assert_eq!(D38s12::ONE.sqrt(), D38s12::ONE);Sourcepub fn cbrt_fast(self) -> Self
pub fn cbrt_fast(self) -> Self
Returns the cube root of self via the f64 bridge.
f64::cbrt is defined for the entire real line, including
negative inputs (cbrt(-8.0) == -2.0). The result is
bit-deterministic across IEEE-754-conformant platforms because
f64::cbrt is correctly-rounded.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
let neg_eight = D38s12::from_int(-8);
let result = neg_eight.cbrt();
assert!((result.to_f64() - (-2.0_f64)).abs() < 1e-9);Sourcepub fn hypot_fast(self, other: Self) -> Self
pub fn hypot_fast(self, other: Self) -> Self
Returns sqrt(self^2 + other^2) without intermediate overflow.
The naive form (self * self + other * other).sqrt() overflows
i128 once either operand approaches sqrt(D38::MAX). This
method uses the scale trick to avoid that:
hypot(a, b) = max(|a|, |b|) * sqrt(1 + (min(|a|, |b|) / max(|a|, |b|))^2)The min/max ratio is in [0, 1], so ratio^2 is also in
[0, 1] and cannot overflow. The outer multiply by large only
overflows when the true hypotenuse genuinely exceeds D38::MAX,
which matches f64::hypot’s contract.
Both inputs are absolute-valued before processing, so
hypot(-a, b) == hypot(a, b).
Edge cases: hypot(0, 0) == 0 (bit-exact via the early return);
hypot(0, x) ~= |x| and hypot(x, 0) ~= |x|.
§Precision
Lossy: involves f64 at some point; result may lose precision.
§Examples
use decimal_scaled::D38s12;
let three = D38s12::from_int(3);
let four = D38s12::from_int(4);
// Pythagorean triple: hypot(3, 4) ~= 5.
assert!((three.hypot(four).to_f64() - 5.0).abs() < 1e-9);Trait Implementations§
Source§impl<const SCALE: u32> Default for D<Int1024, SCALE>
Available on crate features d307 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int1024.
impl<const SCALE: u32> Default for D<Int1024, SCALE>
d307 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int1024.
Implemented on the underlying crate::D<crate::wide_int::Int1024, SCALE>
because D307<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int1536, SCALE>
Available on crate features d462 or x-wide only.Default returns ZERO, matching the all-zero limb pattern of
Int1536.
impl<const SCALE: u32> Default for D<Int1536, SCALE>
d462 or x-wide only.Default returns ZERO, matching the all-zero limb pattern of
Int1536.
Implemented on the underlying crate::D<crate::wide_int::Int1536, SCALE>
because D462<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int192, SCALE>
Available on crate features d57 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int192.
impl<const SCALE: u32> Default for D<Int192, SCALE>
d57 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int192.
Implemented on the underlying crate::D<crate::wide_int::Int192, SCALE>
because D57<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int2048, SCALE>
Available on crate features d616 or x-wide only.Default returns ZERO, matching the all-zero limb pattern of
Int2048.
impl<const SCALE: u32> Default for D<Int2048, SCALE>
d616 or x-wide only.Default returns ZERO, matching the all-zero limb pattern of
Int2048.
Implemented on the underlying crate::D<crate::wide_int::Int2048, SCALE>
because D616<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int256, SCALE>
Available on crate features d76 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int256.
impl<const SCALE: u32> Default for D<Int256, SCALE>
d76 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int256.
Implemented on the underlying crate::D<crate::wide_int::Int256, SCALE>
because D76<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int3072, SCALE>
Available on crate features d924 or xx-wide only.Default returns ZERO, matching the all-zero limb pattern of
Int3072.
impl<const SCALE: u32> Default for D<Int3072, SCALE>
d924 or xx-wide only.Default returns ZERO, matching the all-zero limb pattern of
Int3072.
Implemented on the underlying crate::D<crate::wide_int::Int3072, SCALE>
because D924<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int384, SCALE>
Available on crate features d115 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int384.
impl<const SCALE: u32> Default for D<Int384, SCALE>
d115 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int384.
Implemented on the underlying crate::D<crate::wide_int::Int384, SCALE>
because D115<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int4096, SCALE>
Available on crate features d1232 or xx-wide only.Default returns ZERO, matching the all-zero limb pattern of
Int4096.
impl<const SCALE: u32> Default for D<Int4096, SCALE>
d1232 or xx-wide only.Default returns ZERO, matching the all-zero limb pattern of
Int4096.
Implemented on the underlying crate::D<crate::wide_int::Int4096, SCALE>
because D1232<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int512, SCALE>
Available on crate features d153 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int512.
impl<const SCALE: u32> Default for D<Int512, SCALE>
d153 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int512.
Implemented on the underlying crate::D<crate::wide_int::Int512, SCALE>
because D153<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<Int768, SCALE>
Available on crate features d230 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int768.
impl<const SCALE: u32> Default for D<Int768, SCALE>
d230 or wide only.Default returns ZERO, matching the all-zero limb pattern of
Int768.
Implemented on the underlying crate::D<crate::wide_int::Int768, SCALE>
because D230<SCALE> is now an alias of that type. ZERO is emitted
by the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<i128, SCALE>
Default returns ZERO, matching i128::default() == 0.
impl<const SCALE: u32> Default for D<i128, SCALE>
Default returns ZERO, matching i128::default() == 0.
This lets #[derive(Default)] work correctly on structs that contain
D38<S> fields.
Implemented on the underlying crate::D<i128, SCALE> because
D38<SCALE> is now an alias of that type. ZERO is emitted by
the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<i32, SCALE>
Default returns ZERO, matching i32::default() == 0.
impl<const SCALE: u32> Default for D<i32, SCALE>
Default returns ZERO, matching i32::default() == 0.
Implemented on the underlying crate::D<i32, SCALE> because
D9<SCALE> is now an alias of that type. ZERO is emitted by
the basics macro further down in this file.
Source§impl<const SCALE: u32> Default for D<i64, SCALE>
Default returns ZERO, matching i64::default() == 0.
impl<const SCALE: u32> Default for D<i64, SCALE>
Default returns ZERO, matching i64::default() == 0.
Implemented on the underlying crate::D<i64, SCALE> because
D18<SCALE> is now an alias of that type. ZERO is emitted by
the basics macro further down in this file.
Source§impl<S: Ord, const SCALE: u32> Ord for D<S, SCALE>
impl<S: Ord, const SCALE: u32> Ord for D<S, 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> PartialEq<D<Int1024, SCALE>> for f32
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for f32
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for f64
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for f64
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i128
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i128
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i16
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i16
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i32
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i32
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i64
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i64
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i8
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for i8
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for isize
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for isize
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u128
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u128
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u16
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u16
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u32
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u32
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u64
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u64
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u8
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for u8
Source§impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for usize
impl<const SCALE: u32> PartialEq<D<Int1024, SCALE>> for usize
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for f32
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for f32
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for f64
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for f64
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i128
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i128
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i16
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i16
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i32
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i32
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i64
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i64
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i8
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for i8
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for isize
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for isize
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u128
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u128
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u16
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u16
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u32
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u32
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u64
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u64
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u8
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for u8
Source§impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for usize
impl<const SCALE: u32> PartialEq<D<Int256, SCALE>> for usize
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for f32
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for f32
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for f64
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for f64
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i128
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i128
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i16
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i16
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i32
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i32
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i64
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i64
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i8
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for i8
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for isize
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for isize
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u128
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u128
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u16
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u16
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u32
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u32
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u64
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u64
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u8
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for u8
Source§impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for usize
impl<const SCALE: u32> PartialEq<D<Int512, SCALE>> for usize
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for f32
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for f32
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for f64
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for f64
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i128
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i128
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i16
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i16
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i32
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i32
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i64
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i64
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i8
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for i8
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for isize
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for isize
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u128
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u128
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u16
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u16
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u32
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u32
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u64
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u64
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u8
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for u8
Source§impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for usize
impl<const SCALE: u32> PartialEq<D<i128, SCALE>> for usize
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for f32
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for f32
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for f64
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for f64
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i128
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i128
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i16
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i16
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i32
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i32
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i64
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i64
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i8
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for i8
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for isize
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for isize
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u128
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u128
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u16
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u16
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u32
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u32
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u64
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u64
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u8
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for u8
Source§impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for usize
impl<const SCALE: u32> PartialEq<D<i64, SCALE>> for usize
Source§impl<S: PartialOrd, const SCALE: u32> PartialOrd for D<S, SCALE>
impl<S: PartialOrd, const SCALE: u32> PartialOrd for D<S, SCALE>
Source§impl<const SCALE: u32> TryFrom<D<Int1024, SCALE>> for D76<SCALE>
impl<const SCALE: u32> TryFrom<D<Int1024, SCALE>> for D76<SCALE>
Source§fn try_from(value: D307<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D307<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<Int1024, SCALE>> for D153<SCALE>
impl<const SCALE: u32> TryFrom<D<Int1024, SCALE>> for D153<SCALE>
Source§fn try_from(value: D307<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D307<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<Int1024, SCALE>> for D230<SCALE>
impl<const SCALE: u32> TryFrom<D<Int1024, SCALE>> for D230<SCALE>
Source§fn try_from(value: D307<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D307<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<Int1536, SCALE>> for D307<SCALE>
impl<const SCALE: u32> TryFrom<D<Int1536, SCALE>> for D307<SCALE>
Source§fn try_from(value: D462<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D462<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<Int192, SCALE>> for D38<SCALE>
impl<const SCALE: u32> TryFrom<D<Int192, 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<Int2048, SCALE>> for D462<SCALE>
impl<const SCALE: u32> TryFrom<D<Int2048, SCALE>> for D462<SCALE>
Source§fn try_from(value: D616<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D616<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<Int256, SCALE>> for D57<SCALE>
impl<const SCALE: u32> TryFrom<D<Int256, SCALE>> for D57<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<Int256, SCALE>> for D38<SCALE>
impl<const SCALE: u32> TryFrom<D<Int256, 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<Int256, SCALE>> for D9<SCALE>
impl<const SCALE: u32> TryFrom<D<Int256, 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.
Source§type Error = ConvertError
type Error = ConvertError
Source§impl<const SCALE: u32> TryFrom<D<Int256, SCALE>> for D18<SCALE>
impl<const SCALE: u32> TryFrom<D<Int256, SCALE>> for D18<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<Int3072, SCALE>> for D616<SCALE>
impl<const SCALE: u32> TryFrom<D<Int3072, SCALE>> for D616<SCALE>
Source§fn try_from(value: D924<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D924<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<Int384, SCALE>> for D76<SCALE>
impl<const SCALE: u32> TryFrom<D<Int384, SCALE>> for D76<SCALE>
Source§fn try_from(value: D115<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D115<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<Int4096, SCALE>> for D924<SCALE>
impl<const SCALE: u32> TryFrom<D<Int4096, SCALE>> for D924<SCALE>
Source§fn try_from(value: D1232<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D1232<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<Int512, SCALE>> for D76<SCALE>
impl<const SCALE: u32> TryFrom<D<Int512, SCALE>> for D76<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.
Source§type Error = ConvertError
type Error = ConvertError
Source§impl<const SCALE: u32> TryFrom<D<Int512, SCALE>> for D115<SCALE>
impl<const SCALE: u32> TryFrom<D<Int512, SCALE>> for D115<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.
Source§type Error = ConvertError
type Error = ConvertError
Source§impl<const SCALE: u32> TryFrom<D<Int512, SCALE>> for D38<SCALE>
impl<const SCALE: u32> TryFrom<D<Int512, 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.
Source§type Error = ConvertError
type Error = ConvertError
Source§impl<const SCALE: u32> TryFrom<D<Int768, SCALE>> for D153<SCALE>
impl<const SCALE: u32> TryFrom<D<Int768, SCALE>> for D153<SCALE>
Source§fn try_from(value: D230<SCALE>) -> Result<Self, Self::Error>
fn try_from(value: D230<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<i128, SCALE>> for D9<SCALE>
impl<const SCALE: u32> TryFrom<D<i128, 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<D<i128, SCALE>> for D18<SCALE>
impl<const SCALE: u32> TryFrom<D<i128, SCALE>> for D18<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<D<i64, SCALE>> for D9<SCALE>
impl<const SCALE: u32> TryFrom<D<i64, 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.