Struct Dec19x19

Source
#[repr(transparent)]
pub struct Dec19x19 { pub repr: i128, }
Expand description

A high-precision, high-performance fixed-point decimal type.

Internally, values are stored as i128, which supports 39 digits with the first digit never exceeding 1. The last 19 digits are interpreted as the fractional part. This allows all operations to perform without rounding or approximations within the full range of exactly 19 fractional and 19 integer digits.

Fields§

§repr: i128

Implementations§

Source§

impl Dec19x19

Source

pub const fn from_repr(repr: i128) -> Self

Creates a new Dec19x19 from the given i128 representation, assuming the last 19 digits are the fractional part.

Source

pub const fn is_zero(self) -> bool

Source§

impl Dec19x19

Source

pub const MAX_INT: Self

The biggest possible integer value that can be stored in a Dec19x19.

§Tests
assert_eq!(Dec19x19::MAX_INT, Dec19x19::MAX.trunc());
Source

pub const MIN_INT: Self

The smallest possible integer value that can be stored in a Dec19x19.

§Tests
assert_eq!(Dec19x19::MIN_INT, Dec19x19::MIN.trunc());
Source

pub const LN_2: Self

The natural logarithm of 2 (ln(2)), accurate to all 19 decimal places of the Dec19x19 fixed-point format.

Source

pub const SMALLEST_STEP: Self

The smallest possible value that can be stored in a Dec19x19.

§Tests
assert_eq!(Dec19x19::SMALLEST_STEP / Dec19x19!(2), Dec19x19!(0));
Source§

impl Dec19x19

Source

pub fn unchecked_mul_no_opt(self, rhs: Self) -> Self

Multiplication without checking for overflow and no optimization for LHS or RHS being ints or fracs only. You probably want to use Dec19x19::mul with mul_opt flag disabled instead.

Source

pub fn unchecked_mul_opt(self, rhs: Self) -> Self

Multiplication without checking for overflow and optimization for LHS or RHS being ints or fracs only. You probably want to use Dec19x19::mul with mul_opt flag enabled instead (default).

Source

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

Multiplication with checking for overflow and no optimization for LHS or RHS being ints. You probably want to use Dec19x19::checked_mul with mul_opt flag disabled instead.

Source

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

Multiplication with checking for overflow and optimization for LHS or RHS being ints. You probably want to use Dec19x19::checked_mul with mul_opt flag enabled instead.

Source§

impl Dec19x19

Source

pub const fn from_i64(value: i64) -> Self

Source§

impl Dec19x19

Source

pub const fn from_i32(value: i32) -> Self

Source§

impl Dec19x19

Source

pub const fn from_i16(value: i16) -> Self

Source§

impl Dec19x19

Source

pub const fn from_i8(value: i8) -> Self

Source§

impl Dec19x19

Source

pub const fn from_u32(value: u32) -> Self

Source§

impl Dec19x19

Source

pub const fn from_u16(value: u16) -> Self

Source§

impl Dec19x19

Source

pub const fn from_u8(value: u8) -> Self

Source§

impl Dec19x19

Source

pub fn try_from_i128( value: i128, ) -> Result<Self, <Self as TryFrom<i128>>::Error>

Source§

impl Dec19x19

Source

pub fn try_from_u64(value: u64) -> Result<Self, <Self as TryFrom<u64>>::Error>

Source§

impl Dec19x19

Source

pub fn try_from_u128( value: u128, ) -> Result<Self, <Self as TryFrom<u128>>::Error>

Source§

impl Dec19x19

Source

pub fn try_from_f32(value: f32) -> Result<Self, <Self as TryFrom<f32>>::Error>

Source§

impl Dec19x19

Source

pub fn try_from_f64(value: f64) -> Result<Self, <Self as TryFrom<f64>>::Error>

Source§

impl Dec19x19

Source

pub fn into_u64(self) -> u64

Source§

impl Dec19x19

Source

pub fn into_i128(self) -> i128

Source§

impl Dec19x19

Source

pub fn into_u128(self) -> u128

Source§

impl Dec19x19

Source

pub fn into_f64(self) -> f64

Source§

impl Dec19x19

Source

pub fn into_f32(self) -> f32

Source§

impl Dec19x19

Source

pub fn try_into_i64(self) -> Result<i64, <i64 as TryFrom<Self>>::Error>

Source§

impl Dec19x19

Source

pub fn try_into_u32(self) -> Result<u32, <u32 as TryFrom<Self>>::Error>

Source§

impl Dec19x19

Source

pub fn try_into_i32(self) -> Result<i32, <i32 as TryFrom<Self>>::Error>

Source§

impl Dec19x19

Source

pub fn try_into_u16(self) -> Result<u16, <u16 as TryFrom<Self>>::Error>

Source§

impl Dec19x19

Source

pub fn try_into_i16(self) -> Result<i16, <i16 as TryFrom<Self>>::Error>

Source§

impl Dec19x19

Source

pub fn try_into_u8(self) -> Result<u8, <u8 as TryFrom<Self>>::Error>

Source§

impl Dec19x19

Source

pub fn try_into_i8(self) -> Result<i8, <i8 as TryFrom<Self>>::Error>

Trait Implementations§

Source§

impl Abs for Dec19x19

§Tests

check!( [Dec19x19::abs] {
    (Dec19x19::MAX)   => Dec19x19::MAX,
    (Dec19x19!(3.0))  => Dec19x19!(3.0),
    (Dec19x19!(0.0))  => Dec19x19!(0.0),
    (Dec19x19!(-3.0)) => Dec19x19!(3.0),
    (Dec19x19::MIN)   => Dec19x19::MAX,
});
Source§

const fn abs(self) -> Self

Source§

impl<'t> Add<&'t Dec19x19> for Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'t Dec19x19) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Dec19x19> for &Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Dec19x19) -> Self::Output

Performs the + operation. Read more
Source§

impl<'t> Add for &'t Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Dec19x19

§Tests

check!( [Dec19x19::add, Dec19x19::checked_add] {
    (Dec19x19::MAX, Dec19x19::MIN) => -Dec19x19::SMALLEST_STEP,
    (Dec19x19::MAX - Dec19x19!(1), Dec19x19!(1)) => Dec19x19::MAX,
    (Dec19x19::MAX, Dec19x19!(0)) => Dec19x19::MAX,
    (Dec19x19::MIN, Dec19x19!(0)) => Dec19x19::MIN,
    (Dec19x19::MAX, Dec19x19::SMALLEST_STEP) => FAIL,
    (Dec19x19::MAX, Dec19x19!(1)) => FAIL,
    (Dec19x19::MIN, -Dec19x19::SMALLEST_STEP) => FAIL
});

§Fuzzy

fuzzy2::<Dec19x19, BigDecimal>(Series::new(0..=18, 0..=19), Series::new(0..=18, 0..=19),
    |(f1, b1), (f2, b2)| should_eq(f1 + f2, b1 + b2)
);
Source§

type Output = Dec19x19

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Dec19x19

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Ceil for Dec19x19

Source§

const fn ceil(self) -> Self

Source§

impl CeilTo for Dec19x19

Source§

const fn ceil_to(self, digits: i64) -> Self

Source§

impl CheckedAdd for Dec19x19

Source§

type Output = Dec19x19

Source§

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

Source§

impl CheckedDiv for Dec19x19

Source§

type Output = Dec19x19

Source§

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

Source§

impl CheckedLn for Dec19x19

Source§

fn checked_ln(self) -> Option<Self>

Source§

impl CheckedLog10Floor for Dec19x19

Source§

const fn checked_log10_floor(self) -> Option<Self>

Source§

impl CheckedMul for Dec19x19

Source§

type Output = Dec19x19

Source§

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

Source§

impl CheckedPow<i32> for Dec19x19

Source§

impl CheckedSqrt for Dec19x19

Source§

fn checked_sqrt(self) -> Option<Self>

Source§

impl CheckedSub for Dec19x19

Source§

type Output = Dec19x19

Source§

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

Source§

impl Clone for Dec19x19

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dec19x19

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Dec19x19

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Dec19x19

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'t> Div<&'t Dec19x19> for Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'t Dec19x19) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Dec19x19> for &Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Dec19x19) -> Self::Output

Performs the / operation. Read more
Source§

impl<'t> Div for &'t Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Dec19x19

§Tests

check! ( [Dec19x19::div, Dec19x19::checked_div] {
    (Dec19x19!(20), Dec19x19!(0.2)) => Dec19x19!(100.0),
    (Dec19x19::MAX, Dec19x19!(-1)) => Dec19x19::MIN + Dec19x19::SMALLEST_STEP,
    (Dec19x19::MIN + Dec19x19::SMALLEST_STEP, Dec19x19!(-1)) => Dec19x19::MAX,
    (Dec19x19::MAX - Dec19x19!(10), Dec19x19!(0.1)) => FAIL,
    (Dec19x19::MAX - Dec19x19!(10), Dec19x19!(0)) => FAIL,
    (Dec19x19!(10), Dec19x19!(0)) => FAIL,
    (Dec19x19::MAX, Dec19x19!(0.1)) => FAIL,
});

§Fuzzy

fuzzy2::<Dec19x19, BigDecimal>(Series::new(0..=9, 0..=9), Series::new(0..=9, 0..=9),
    |(f1, b1), (f2, b2)| should_eq(f1 / f2, b1 / b2)
);
Source§

type Output = Dec19x19

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign for Dec19x19

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl Floor for Dec19x19

Source§

const fn floor(self) -> Self

Source§

impl FloorTo for Dec19x19

Source§

const fn floor_to(self, digits: i64) -> Self

Source§

impl Format for Dec19x19

Source§

fn format(&self, f: &mut Formatter) -> String

Source§

impl From<Dec19x19> for f32

Source§

fn from(value: Dec19x19) -> Self

Converts to this type from the input type.
Source§

impl From<Dec19x19> for f64

Source§

fn from(value: Dec19x19) -> Self

Converts to this type from the input type.
Source§

impl From<Dec19x19> for i128

Source§

fn from(value: Dec19x19) -> Self

Converts to this type from the input type.
Source§

impl From<Dec19x19> for u128

Source§

fn from(value: Dec19x19) -> Self

Converts to this type from the input type.
Source§

impl From<Dec19x19> for u64

Source§

fn from(value: Dec19x19) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Dec19x19

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Dec19x19

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Dec19x19

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Dec19x19

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Dec19x19

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Dec19x19

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Dec19x19

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Dec19x19

§Tests

use std::str::FromStr;
assert_eq!(Dec19x19!(17_014_118_346_046_923_173.168_730_371_588_410_572_7).repr, i128::MAX);
assert_eq!(Dec19x19!(-17_014_118_346_046_923_173.168_730_371_588_410_572_8).repr, i128::MIN);
assert_eq!(Dec19x19!(987e-19), Dec19x19!(0.000_000_000_000_000_098_7));
assert_eq!(Dec19x19!(987e-2), Dec19x19!(9.87));
assert_eq!(Dec19x19!(987e-1), Dec19x19!(98.7));
assert_eq!(Dec19x19!(987e-0), Dec19x19!(987));
assert_eq!(Dec19x19!(987e0), Dec19x19!(987));
assert_eq!(Dec19x19!(987e+0), Dec19x19!(987));
assert_eq!(Dec19x19!(987e+1), Dec19x19!(9_870));
assert_eq!(Dec19x19!(987e+2), Dec19x19!(98_700));
assert_eq!(Dec19x19!(987e16), Dec19x19!(9_870_000_000_000_000_000));
assert_eq!(Dec19x19!(1_000_000_000_000_000e-34), Dec19x19::SMALLEST_STEP);
assert_eq!(Dec19x19!(0.000_000_000_000_000e34), Dec19x19!(0));
assert!(Dec19x19::from_str("17_014_118_346_046_923_173.168_730_371_588_410_572_8").is_err());
assert!(Dec19x19::from_str("-17_014_118_346_046_923_173.168_730_371_588_410_572_9").is_err());
assert!(Dec19x19::from_str("987e+17").is_err());
assert!(Dec19x19::from_str("987e-20").is_err());
Source§

type Err = ParseDec19x19Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl HasMax for Dec19x19

The biggest possible value that can be stored in a Dec19x19, equal to

17_014_118_346_046_923_173.168_730_371_588_410_572_7
Source§

const MAX: Self

Source§

const fn is_max(self) -> bool

Source§

impl HasMin for Dec19x19

The smallest possible value that can be stored in a Dec19x19, equal to

-17_014_118_346_046_923_173.168_730_371_588_410_572_8
Source§

const MIN: Self

Source§

const fn is_min(self) -> bool

Source§

impl<'t> Mul<&'t Dec19x19> for Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'t Dec19x19) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Dec19x19> for &Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Dec19x19) -> Self::Output

Performs the * operation. Read more
Source§

impl<'t> Mul for &'t Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Dec19x19

§Tests

check!(
    [
        Dec19x19::unchecked_mul_no_opt,
        Dec19x19::unchecked_mul_opt,
        Dec19x19::checked_mul_no_opt,
        Dec19x19::checked_mul_opt,
    ] {
    (Dec19x19!(20), Dec19x19!(2.2)) => Dec19x19!(44.0),
    (Dec19x19::MAX, Dec19x19!(10)) => FAIL,
    (Dec19x19::MAX - Dec19x19!(10), Dec19x19!(2)) => FAIL,
});

§Fuzzy

let series = [
    Series::new(0..=9, 0..=19),
    Series::new(9, 19),
    Series::new(0, 19),
    Series::new(9, 0),
];
for s in series {
    fuzzy2::<Dec19x19, BigDecimal>(s.clone(), s,
        |(f1, b1), (f2, b2)| {
            should_eq(f1.unchecked_mul_opt(f2), b1.clone() * b2.clone());
            should_eq(f1.unchecked_mul_no_opt(f2), b1.clone() * b2.clone());
            should_eq(f1.checked_mul_opt(f2).unwrap(), b1.clone() * b2.clone());
            should_eq(f1.checked_mul_no_opt(f2).unwrap(), b1 * b2);
        }
    );
}
Source§

type Output = Dec19x19

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign for Dec19x19

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl Neg for Dec19x19

§Tests

check! ( [Dec19x19::neg] {
    (Dec19x19::MAX)   => Dec19x19::MIN + Dec19x19::SMALLEST_STEP,
    (Dec19x19!(3.0))  => Dec19x19!(-3.0),
    (Dec19x19!(0.0))  => Dec19x19!(0.0),
    (Dec19x19!(-3.0)) => Dec19x19!(3.0),
    (Dec19x19::MIN)   => Dec19x19::MAX,
    ((Dec19x19::MIN + Dec19x19::SMALLEST_STEP)) => Dec19x19::MAX,
});
Source§

type Output = Dec19x19

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Ord for Dec19x19

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Dec19x19

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Dec19x19

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Rand for Dec19x19

Generates a deterministic random Dec19x19 value using a seed, an integer precision, and a fractional precision. Never returns zero.

§Tests

check! ( [Dec19x19::rand] {
    (0,  6, 0) => Dec19x19!(-758_415),
    (1,  6, 0) => Dec19x19!(-717_558),
    (2,  6, 0) => Dec19x19!(-149_577),
    (3,  6, 0) => Dec19x19!(-442_649),
    (4,  6, 0) => Dec19x19!( 658_419),
    (5,  6, 0) => Dec19x19!( 165_296),

    (6,  3, 0) => Dec19x19!(-787),
    (7,  3, 0) => Dec19x19!(-354),
    (8,  3, 0) => Dec19x19!( 745),
    (9,  3, 0) => Dec19x19!( 163),
    (10, 3, 0) => Dec19x19!(-211),
    (11, 3, 0) => Dec19x19!(-719),

    (12, 3, 3) => Dec19x19!(-698.488),
    (13, 3, 3) => Dec19x19!( 354.710),
    (14, 3, 3) => Dec19x19!( 807.648),
    (15, 3, 3) => Dec19x19!(-392.145),
    (16, 3, 3) => Dec19x19!(-243.552),
    (17, 3, 3) => Dec19x19!( 378.313),

    (18, 6, 6) => Dec19x19!( 428_879.493_071),
    (19, 6, 6) => Dec19x19!( 414_719.622_665),
    (20, 6, 6) => Dec19x19!( 154_184.335_022),
    (21, 6, 6) => Dec19x19!( 335_592.781_210),
    (22, 6, 6) => Dec19x19!(-562_472.732_119),
    (23, 6, 6) => Dec19x19!(-990_435.673_210),

    (0, 0, 6) => Dec19x19!(-0.758_415),
    (1, 0, 6) => Dec19x19!(-0.617_558),
    (2, 0, 6) => Dec19x19!(-0.049_577),
    (3, 0, 6) => Dec19x19!(-0.342_649),
    (4, 0, 6) => Dec19x19!( 0.658_419),
    (5, 0, 6) => Dec19x19!( 0.065_296),

    (1, 19, 19) => Dec19x19!(-7_175_586_050_193_843_404.647_199_936_274_331_797_4),

    (0, 0, 0) => Dec19x19!(-7),
    (1, 0, 0) => Dec19x19!(-6),
    (2, 0, 0) => Dec19x19!(-1),
    (3, 0, 0) => Dec19x19!(-3),
    (4, 0, 0) => Dec19x19!(6),
    (5, 0, 0) => Dec19x19!(1),

    (1, 0..=9, 0..=9) => Dec19x19!(42545517.614973869),
    (2, 0..=9, 0..=9) => Dec19x19!(-0.41),
    (3, 0..=9, 0..=9) => Dec19x19!(-224053),
    (4, 0..=9, 0..=9) => Dec19x19!(662259.83081),
    (5, 0..=9, 0..=9) => Dec19x19!(-5.748),
});
Source§

fn rand(seed: u64, int: impl IntoRandRange, frac: impl IntoRandRange) -> Self

Source§

impl Rem for Dec19x19

§Tests

check!( [Dec19x19::rem] {
    (Dec19x19!(14.7), Dec19x19!(5))             => Dec19x19!(4.7),
    (Dec19x19!(14.7), Dec19x19!(0))             => Dec19x19!(14.7),
    (Dec19x19!(14.7), Dec19x19::SMALLEST_STEP)  => Dec19x19!(0),
    (Dec19x19::MAX,   Dec19x19::SMALLEST_STEP)  => Dec19x19!(0),
    (Dec19x19::MIN,   -Dec19x19::SMALLEST_STEP) => Dec19x19!(0),
    (Dec19x19::MAX,   Dec19x19::MAX)            => Dec19x19!(0),
    (Dec19x19::MIN,   Dec19x19::MIN)            => Dec19x19!(0),
    (Dec19x19::MAX,   Dec19x19::MIN)            => Dec19x19::MAX,
    (Dec19x19::MIN,   Dec19x19::MAX)            => -Dec19x19::SMALLEST_STEP,
});
Source§

type Output = Dec19x19

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl Round for Dec19x19

Source§

const fn round(self) -> Self

Source§

impl RoundTo for Dec19x19

Source§

const fn round_to(self, digits: i64) -> Self

Source§

impl SaturatingAdd for Dec19x19

§Tests

check! ( [Dec19x19::saturating_add] {
    (Dec19x19::MAX,  Dec19x19::SMALLEST_STEP) => Dec19x19::MAX,
    (Dec19x19::MIN, -Dec19x19::SMALLEST_STEP) => Dec19x19::MIN,
});
Source§

type Output = Dec19x19

Source§

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

Source§

impl SaturatingDiv for Dec19x19

§Tests

assert_eq!((Dec19x19::MAX - Dec19x19!(10)).saturating_div(Dec19x19!(0.1)), Dec19x19::MAX);
assert_eq!((Dec19x19::MAX - Dec19x19!(10)).saturating_div(Dec19x19!(-0.1)), Dec19x19::MIN);
assert_eq!(Dec19x19::MIN.saturating_div(Dec19x19!(-1)), Dec19x19::MAX);
Source§

type Output = Dec19x19

Source§

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

Source§

impl SaturatingMul for Dec19x19

§Tests

check! ( [Dec19x19::saturating_mul] {
    (Dec19x19::MAX - Dec19x19!(10), Dec19x19!(2)) => Dec19x19::MAX,
    (Dec19x19::MAX - Dec19x19!(10), Dec19x19!(-2)) => Dec19x19::MIN,
});
Source§

type Output = Dec19x19

Source§

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

Source§

impl SaturatingSub for Dec19x19

§Tests

check! ( [Dec19x19::saturating_sub] {
    (Dec19x19::MIN, Dec19x19!(1))  => Dec19x19::MIN,
    (Dec19x19!(10), Dec19x19::MIN) => Dec19x19::MAX,
    (Dec19x19!(0), Dec19x19::MIN)  => Dec19x19::MAX,
});
Source§

type Output = Dec19x19

Source§

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

Source§

impl Signum for Dec19x19

§Tests

check! ( [Dec19x19::signum] {
    (Dec19x19::MAX)   => Dec19x19!(1.0),
    (Dec19x19!(3.0))  => Dec19x19!(1.0),
    (Dec19x19!(0.0))  => Dec19x19!(0.0),
    (Dec19x19!(-3.0)) => Dec19x19!(-1.0),
    (Dec19x19::MIN)   => Dec19x19!(-1.0),
});
Source§

const fn signum(self) -> Self

Source§

const fn signum_i128(self) -> i128

Source§

impl Step for Dec19x19

Source§

fn forward(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
Source§

fn backward(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
Source§

unsafe fn forward_unchecked(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
Source§

unsafe fn backward_unchecked(start: Self, count: usize) -> Self

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
Source§

fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>)

🔬This is a nightly-only experimental API. (step_trait)
Returns the bounds on the number of successor steps required to get from start to end like Iterator::size_hint(). Read more
Source§

fn forward_checked(start: Self, count: usize) -> Option<Self>

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the successor of self count times. Read more
Source§

fn backward_checked(start: Self, count: usize) -> Option<Self>

🔬This is a nightly-only experimental API. (step_trait)
Returns the value that would be obtained by taking the predecessor of self count times. Read more
Source§

impl<'t> Sub<&'t Dec19x19> for Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'t Dec19x19) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Dec19x19> for &Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Dec19x19) -> Self::Output

Performs the - operation. Read more
Source§

impl<'t> Sub for &'t Dec19x19

Source§

type Output = Dec19x19

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Dec19x19

§Tests

check!( [Dec19x19::sub, Dec19x19::checked_sub] {
    (Dec19x19::MIN + Dec19x19!(1), Dec19x19!(1)) => Dec19x19::MIN,
    (-Dec19x19::SMALLEST_STEP, Dec19x19::MIN) => Dec19x19::MAX,
    (Dec19x19::MIN, Dec19x19::SMALLEST_STEP) => FAIL,
    (Dec19x19::MIN, Dec19x19!(1)) => FAIL,
    (Dec19x19!(0), Dec19x19::MIN) => FAIL,
});

§Fuzzy

fuzzy2::<Dec19x19, BigDecimal>(Series::new(0..=18, 0..=19), Series::new(0..=18, 0..=19),
    |(f1, b1), (f2, b2)| should_eq(f1 - f2, b1 - b2)
);
Source§

type Output = Dec19x19

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for Dec19x19

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Trunc for Dec19x19

Source§

const fn trunc(self) -> Self

Source§

impl TruncTo for Dec19x19

Source§

const fn trunc_to(self, digits: i64) -> Self

Source§

impl TryFrom<Dec19x19> for i16

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Dec19x19) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Dec19x19> for i32

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Dec19x19) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Dec19x19> for i64

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Dec19x19) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Dec19x19> for i8

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Dec19x19) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Dec19x19> for u16

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Dec19x19) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Dec19x19> for u32

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Dec19x19) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Dec19x19> for u8

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: Dec19x19) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<f32> for Dec19x19

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: f32) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<f64> for Dec19x19

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: f64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<i128> for Dec19x19

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: i128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u128> for Dec19x19

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: u128) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<u64> for Dec19x19

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl UncheckedAdd for Dec19x19

Source§

type Output = Dec19x19

Source§

const fn unchecked_add(self, rhs: Self) -> Self

Source§

impl UncheckedDiv for Dec19x19

Source§

type Output = Dec19x19

Source§

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

Source§

impl UncheckedLn for Dec19x19

§Tests

let trunc = |t: Dec19x19| t.trunc_to(17);
check!( [|t| trunc(Dec19x19::unchecked_ln(t)), |t| Dec19x19::checked_ln(t).map(trunc)] {
    (Dec19x19::MAX) =>  trunc(Dec19x19!(44.280_575_164_226_186_298_3)),
    (Dec19x19!(10)) =>  trunc(Dec19x19!(2.302_585_092_994_045_684_0)),
    (Dec19x19!(100)) => trunc(Dec19x19!(4.605_170_185_988_091_367_8)),
    (Dec19x19!(0.1)) => trunc(Dec19x19!(-2.302_585_092_994_045_683_7)),
    (Dec19x19!(2.718281828459045239)) => Dec19x19!(1),
    (-Dec19x19::SMALLEST_STEP) => FAIL,
});
Source§

fn unchecked_ln(self) -> Self

Source§

impl UncheckedLog10Floor for Dec19x19

§Tests

check! ( [Dec19x19::unchecked_log10_floor, Dec19x19::checked_log10_floor] {
    (Dec19x19::MAX)   => Dec19x19!(19),
    (Dec19x19!(10.1)) => Dec19x19!(1),
    (Dec19x19!(10.0)) => Dec19x19!(1),
    (Dec19x19!(9.99)) => Dec19x19!(0),
    (Dec19x19!(1.17)) => Dec19x19!(0),
    (Dec19x19!(1.0))  => Dec19x19!(0),
    (Dec19x19!(0.9))  => Dec19x19!(-1),
    (Dec19x19!(0.11)) => Dec19x19!(-1),
    (Dec19x19!(0.1))  => Dec19x19!(-1),
    (Dec19x19!(0.09)) => Dec19x19!(-2),
    (-Dec19x19::SMALLEST_STEP) => FAIL,
});
Source§

const fn unchecked_log10_floor(self) -> Self

Source§

impl UncheckedMul for Dec19x19

Source§

type Output = Dec19x19

Source§

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

Source§

impl UncheckedPow<i32> for Dec19x19

check! ( [Dec19x19::unchecked_pow, Dec19x19::checked_pow] {
    // Identity and basic powers
    (Dec19x19!(2), 0_i32) => Dec19x19!(1),
    (Dec19x19!(2), 1_i32) => Dec19x19!(2),
    (Dec19x19!(2), 3_i32) => Dec19x19!(8),
    (Dec19x19!(2), 4_i32) => Dec19x19!(16),
    (Dec19x19!(2), 5_i32) => Dec19x19!(32),
    (Dec19x19!(2), 6_i32) => Dec19x19!(64),
    (Dec19x19!(2), 7_i32) => Dec19x19!(128),
    (Dec19x19!(2), 8_i32) => Dec19x19!(256),
    (Dec19x19!(2), 9_i32) => Dec19x19!(512),
    (Dec19x19!(2), 10_i32) => Dec19x19!(1024),
    (Dec19x19!(2), 11_i32) => Dec19x19!(2048),
    (Dec19x19!(2), 12_i32) => Dec19x19!(4096),
    (Dec19x19!(2), 13_i32) => Dec19x19!(8192),
    (Dec19x19!(2), 14_i32) => Dec19x19!(16384),
    (Dec19x19!(2), 15_i32) => Dec19x19!(32768),
    (Dec19x19!(2), 16_i32) => Dec19x19!(65536),

    // Zero exponent
    (Dec19x19!(20), 0) => Dec19x19!(1),

    // Negative exponents
    (Dec19x19!(2), -1_i32) => Dec19x19!(0.5),
    (Dec19x19!(2), -2_i32) => Dec19x19!(0.25),

    // Fractional bases
    (Dec19x19!(0.5), 2_i32) => Dec19x19!(0.25),
    (Dec19x19!(0.5), 3_i32) => Dec19x19!(0.125),
    (Dec19x19!(0.5), -1_i32) => Dec19x19!(2.0),

    // Fractional result rounding
    (Dec19x19!(1.1), 2_i32) => Dec19x19!(1.21),
    (Dec19x19!(1.5), 2_i32) => Dec19x19!(2.25),

    // Larger integer base
    (Dec19x19!(10), 3_i32) => Dec19x19!(1000),

    (Dec19x19::MAX, -1_i32) => Dec19x19!(0),

    (Dec19x19!(2), 63_i32) => Dec19x19!(9_223_372_036_854_775_808),
    (Dec19x19!(2), 64) => FAIL,

    (Dec19x19!(0), -1_i32) => FAIL,
    (Dec19x19::MAX, 2_i32) => FAIL,
    (Dec19x19::MIN, 2_i32) => FAIL,
});
Source§

impl UncheckedSqrt for Dec19x19

§Tests

check! ( [Dec19x19::unchecked_sqrt, Dec19x19::checked_sqrt] {
    (Dec19x19!(0)) => Dec19x19!(0),
    (Dec19x19::MAX) => Dec19x19!(4_124_817_371.235_594_858_790_322_117_5),
    (-Dec19x19::SMALLEST_STEP) => FAIL,
});
// Precision test.
assert_eq!(Dec19x19!(1e-18).unchecked_sqrt() * Dec19x19!(1e-18).unchecked_sqrt(), Dec19x19!(1e-18));

§Validation

fuzzy1::<Dec19x19, BigDecimal>(Series::new(0..=19, 0..=19),
    |f1, b1| should_eq(f1.abs().unchecked_sqrt(), b1.abs().sqrt().unwrap())
);
Source§

fn unchecked_sqrt(self) -> Self

Source§

impl UncheckedSub for Dec19x19

Source§

type Output = Dec19x19

Source§

const fn unchecked_sub(self, rhs: Self) -> Self

Source§

impl UnwrapAll for Dec19x19

Source§

impl Copy for Dec19x19

Source§

impl Eq for Dec19x19

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V