Skip to main content

Decimal

Struct Decimal 

Source
pub struct Decimal<const N: usize> { /* private fields */ }
Expand description

§Decimal

Generic signed N-bits decimal number.

Implementations§

Source§

impl<const N: usize> Decimal<N>

Source

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

Converts u8 to Decimal.

Source

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

Converts u16 to Decimal.

Source

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

Converts u32 to Decimal.

Source

pub const fn from_u64(n: u64) -> Self

Converts u64 to Decimal.

Source

pub const fn from_u128(n: u128) -> Result<Self, ParseError>

Converts u128 to Decimal.

Source

pub const fn from_usize(n: usize) -> Self

Converts usize to Decimal.

Source

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

Converts i8 to Decimal.

Source

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

Converts i16 to Decimal.

Source

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

Converts i32 to Decimal.

Source

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

Converts i64 to Decimal.

Source

pub const fn from_i128(n: i128) -> Result<Self, ParseError>

Converts i128 to Decimal.

Source

pub const fn from_isize(n: isize) -> Self

Converts isize to Decimal.

Source

pub const fn from_f32(n: f32) -> Self

Converts f32 to Decimal.

Source

pub const fn from_f64(n: f64) -> Self

Converts f64 to Decimal.

Source§

impl<const N: usize> Decimal<N>

Source

pub const fn to_u8(self) -> Result<u8, ParseError>

Converts Decimal into u8.

Source

pub const fn to_u16(self) -> Result<u16, ParseError>

Converts Decimal into u16.

Source

pub const fn to_u32(self) -> Result<u32, ParseError>

Converts Decimal into u32.

Source

pub const fn to_u64(self) -> Result<u64, ParseError>

Converts Decimal into u64.

Source

pub const fn to_u128(self) -> Result<u128, ParseError>

Converts Decimal into u128.

Source

pub const fn to_usize(self) -> Result<usize, ParseError>

Converts Decimal into usize.

Source

pub const fn to_i8(self) -> Result<i8, ParseError>

Converts Decimal into i8.

Source

pub const fn to_i16(self) -> Result<i16, ParseError>

Converts Decimal into i16.

Source

pub const fn to_i32(self) -> Result<i32, ParseError>

Converts Decimal into i32.

Source

pub const fn to_i64(self) -> Result<i64, ParseError>

Converts Decimal into i64.

Source

pub const fn to_i128(self) -> Result<i128, ParseError>

Converts Decimal into i128.

Source

pub const fn to_isize(self) -> Result<isize, ParseError>

Converts Decimal into isize.

Source§

impl<const N: usize> Decimal<N>

Source

pub const fn to_f32(self) -> f32

Converts Decimal into f32.

Source

pub const fn to_f64(self) -> f64

Converts Decimal into f64.

Source§

impl<const N: usize> Decimal<N>

Source

pub const NAN: Self

Not A Number value. More about NaN.

Source

pub const INFINITY: Self

Infinity (∞). More about ±Infinity.

Source

pub const NEG_INFINITY: Self

Negative infinity (−∞). More about ±Infinity.

Source

pub const MIN: Self

The smallest value that can be represented by this decimal type - (2N - 1) × 1032’768.

Source

pub const MAX: Self

The maximum value that this type can represent (2N - 1) × 1032’768.

Source

pub const MIN_POSITIVE: Self

The smallest positive, normalized value that this type can represent.

Source

pub const EPSILON: Self

Machine epsilon value.

This is the difference between 1.0 and the next larger representable number.

Source

pub const ZERO: Self

The value of 0 represented by this decimal type.

Source

pub const ONE: Self

The value of 1 represented by this decimal type.

Source

pub const TWO: Self

The value of 2 represented by this decimal type.

Source

pub const THREE: Self

The value of 3 represented by this decimal type.

Source

pub const FOUR: Self

The value of 4 represented by this decimal type.

Source

pub const FIVE: Self

The value of 5 represented by this decimal type.

Source

pub const SIX: Self

The value of 6 represented by this decimal type.

Source

pub const SEVEN: Self

The value of 7 represented by this decimal type.

Source

pub const EIGHT: Self

The value of 8 represented by this decimal type.

Source

pub const NINE: Self

The value of 9 represented by this decimal type.

Source

pub const TEN: Self

The value of 10 represented by this decimal type.

Source

pub const HALF: Self

The value of 0.5 represented by this decimal type.

Source

pub const E: Self

Euler’s number (e).

Source

pub const PI: Self

Archimedes’ constant (π).

Source

pub const TAU: Self

The full circle constant (τ)

Equal to 2π.

Source

pub const FRAC_1_PI: Self

1/π.

Source

pub const FRAC_2_PI: Self

2/π.

Source

pub const FRAC_PI_2: Self

π/2.

Source

pub const FRAC_PI_3: Self

π/3.

Source

pub const FRAC_PI_4: Self

π/4.

Source

pub const FRAC_PI_6: Self

π/6.

Source

pub const FRAC_PI_8: Self

π/8.

Source

pub const FRAC_2_SQRT_PI: Self

2/sqrt(π).

Source

pub const LN_2: Self

ln(2).

Source

pub const LN_10: Self

ln(10).

Source

pub const LOG2_E: Self

log2(e).

Source

pub const LOG10_E: Self

log10(e).

Source

pub const SQRT_2: Self

sqrt(2).

Source

pub const FRAC_1_SQRT_2: Self

1/sqrt(2).

Source

pub const LOG10_2: Self

log10(2).

Source

pub const LOG2_10: Self

log2(10).

Source§

impl<const N: usize> Decimal<N>

Source

pub const fn from_parts( digits: UInt<N>, exp: i32, sign: Sign, ctx: Context, ) -> Self

Creates and initializes decimal from parts.

§Examples
use fastnum::{*, decimal::*};

assert_eq!(D256::from_parts(u256!(12345), -4, Sign::Minus, Context::default()), dec256!(-1.2345));
Source

pub const fn from_str(s: &str, ctx: Context) -> Result<Self, ParseError>

Creates and initializes decimal from string.

§Examples
use fastnum::{*, decimal::*};

assert_eq!(D256::from_str("-1.2345", Context::default()), Ok(dec256!(-1.2345)));
Source

pub const fn parse_str(s: &str, ctx: Context) -> Self

Parse decimal from string.

§Panics

This function will panic if Decimal<N> can’t be constructed from a given string.

§Examples
use fastnum::{*, decimal::*};

assert_eq!(D256::parse_str("1.2345", Context::default()), dec256!(1.2345));
use fastnum::{*, decimal::*};

let _ = D256::parse_str("Hello", Context::default());
Source

pub const fn digits(&self) -> UInt<N>

Returns the internal big integer, representing the Coefficient of a given Decimal, including significant trailing zeros.

§Examples
use fastnum::{dec256, u256};

let a = dec256!(-123.45);
assert_eq!(a.digits(), u256!(12345));

let b = dec256!(-1.0);
assert_eq!(b.digits(), u256!(10));
Source

pub const fn digits_count(&self) -> usize

Return the count of digits in the non-scaled integer representation

Source

pub const fn fractional_digits_count(&self) -> i16

Return the scale of the Decimal, the total number of digits to the right of the decimal point (including insignificant leading zeros).

§Examples:
use fastnum::dec256;

let a = dec256!(12345);  // No fractional part
let b = dec256!(123.45);  // Fractional part
let c = dec256!(0.0000012345);  // Completely fractional part
let d = dec256!(500000000);  // No fractional part
let e = dec256!(5e9);  // Negative-fractional part

assert_eq!(a.fractional_digits_count(), 0);
assert_eq!(b.fractional_digits_count(), 2);
assert_eq!(c.fractional_digits_count(), 10);
assert_eq!(d.fractional_digits_count(), 0);
assert_eq!(e.fractional_digits_count(), -9);
Source

pub const fn sign(&self) -> Sign

Return the sign of the Decimal as Sign.

§Examples
use fastnum::{decimal::Sign, dec256};

assert_eq!(dec256!(-1.0).sign(), Sign::Minus);
assert_eq!(dec256!(0.0).sign(),  Sign::Plus);
assert_eq!(dec256!(+1.0).sign(),  Sign::Plus);
Source

pub const fn is_op_div_by_zero(&self) -> bool

Returns true if the given decimal number is the result of division by zero and false otherwise.

§Examples
use fastnum::{*, decimal::*};

let ctx = Context::default().with_signal_traps(SignalsTraps::empty());
let res = dec256!(1.0).with_ctx(ctx) / dec256!(0).with_ctx(ctx);

assert!(res.is_op_div_by_zero());

More about OP_DIV_BY_ZERO signal.

Source

pub const fn is_op_overflow(&self) -> bool

Return true if the argument has Signals::OP_OVERFLOW signal flag, and false otherwise.

Source

pub const fn is_op_underflow(&self) -> bool

Return true if the argument has Signals::OP_UNDERFLOW signal flag, and false otherwise.

Source

pub const fn is_op_invalid(&self) -> bool

Return true if the argument has Signals::OP_INVALID signal flag, and false otherwise.

Source

pub const fn is_op_subnormal(&self) -> bool

Return true if the argument has Signals::OP_SUBNORMAL signal flag, and false otherwise.

Source

pub const fn is_op_inexact(&self) -> bool

Return true if the argument has Signals::OP_INEXACT signal flag, and false otherwise.

Source

pub const fn is_op_rounded(&self) -> bool

Return true if the argument has Signals::OP_ROUNDED signal flag, and false otherwise.

Source

pub const fn is_op_clamped(&self) -> bool

Return true if the argument has Signals::OP_CLAMPED signal flag, and false otherwise.

Source

pub const fn is_op_ok(&self) -> bool

Return true if the argument has no signal flags, and false otherwise.

Source

pub const fn op_signals(&self) -> Signals

Return the signaling block of given decimal.

Source

pub const fn classify(&self) -> FpCategory

Return the decimal category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead.

§Examples
use core::num::FpCategory;
use fastnum::{dec256, D256};

let num = dec256!(12.4);
let inf = D256::INFINITY;

assert_eq!(num.classify(), FpCategory::Normal);
assert_eq!(inf.classify(), FpCategory::Infinite);
Source

pub const fn is_normal(&self) -> bool

Return true if the number is neither zero, ±Infinity, subnormal, or NaN and false otherwise.

§Examples
use fastnum::*;

let num = dec256!(12.4);
let subnormal = dec256!(1E-30000) / dec256!(1E2768);
let inf = D256::INFINITY;
let nan = D256::NAN;
let zero = D256::ZERO;

assert!(num.is_normal());

assert!(!zero.is_normal());
assert!(!nan.is_normal());
assert!(!nan.is_normal());
assert!(!subnormal.is_normal());
Source

pub const fn is_subnormal(&self) -> bool

Return true if the number is subnormal and false otherwise.

§Examples
use fastnum::*;

let num = dec256!(12.4);
let subnormal = dec256!(1E-30000) / dec256!(1E2768);
let inf = D256::INFINITY;
let nan = D256::NAN;
let zero = D256::ZERO;

assert!(subnormal.is_subnormal());

assert!(!num.is_subnormal());
assert!(!zero.is_subnormal());
assert!(!nan.is_subnormal());
assert!(!nan.is_subnormal());
Source

pub const fn is_finite(&self) -> bool

Return true if this number is neither ±Infinity nor NaN and false otherwise.

§Examples
use fastnum::{D256, dec256};

let d = dec256!(7.0);
let inf = D256::INFINITY;
let neg_inf = D256::NEG_INFINITY;
let nan = D256::NAN;

assert!(d.is_finite());

assert!(!nan.is_finite());
assert!(!inf.is_finite());
assert!(!neg_inf.is_finite());
Source

pub const fn is_infinite(&self) -> bool

Return true if this value is positive or negative Infinity and false otherwise.

§Examples
use fastnum::{D256, dec256};

let d = dec256!(7.0);
let inf = D256::INFINITY;
let neg_inf = D256::NEG_INFINITY;
let nan = D256::NAN;

assert!(inf.is_infinite());
assert!(neg_inf.is_infinite());

assert!(!d.is_infinite());
assert!(!nan.is_infinite());
Source

pub const fn is_nan(&self) -> bool

Return true if this value is NaN and false otherwise.

§Examples
use fastnum::{D256, dec256};

let nan = D256::NAN;
let d = dec256!(7.0);

assert!(nan.is_nan());
assert!(!d.is_nan());
Source

pub const fn is_sign_positive(&self) -> bool

Return true if this value is positive, including +0.0, +Infinity and NaN, and false otherwise.

§Examples
use fastnum::{D256, dec256};

let d = dec256!(7.0);
let neg_zero = dec256!(-0.0);
let neg_d = dec256!(-7.0);

assert!(d.is_sign_positive());
assert!(D256::ZERO.is_sign_positive());
assert!(D256::INFINITY.is_sign_positive());
assert!(D256::NAN.is_sign_positive());

assert!(!neg_d.is_sign_positive());
assert!(!neg_zero.is_sign_positive());
assert!(!D256::NEG_INFINITY.is_sign_positive());
Source

pub const fn is_sign_negative(&self) -> bool

Return true if this value is negative, including -0.0 and -Infinity and false otherwise.

§Examples
use fastnum::{D256, dec256};

let d = dec256!(7.0);
let neg_zero = dec256!(-0.0);
let neg_d = dec256!(-7.0);

assert!(neg_d.is_sign_negative());
assert!(neg_zero.is_sign_negative());
assert!(D256::NEG_INFINITY.is_sign_negative());

assert!(!d.is_sign_negative());
assert!(!D256::ZERO.is_sign_negative());
assert!(!D256::INFINITY.is_sign_negative());
assert!(!D256::NAN.is_sign_negative());
Source

pub const fn is_zero(&self) -> bool

Return true if the referenced decimal is ±0.0 and false otherwise.

§Examples
use fastnum::*;

let a = dec256!(0);
assert!(a.is_zero());

let b = dec256!(0.0);
assert!(b.is_zero());

let c = dec256!(-0.00);
assert!(c.is_zero());

let d = dec256!(-0.1);
assert!(!d.is_zero());
Source

pub const fn is_one(&self) -> bool

Return true if the referenced decimal is strictly 1 and false otherwise.

§Examples
use fastnum::*;

let a = dec256!(1);
assert!(a.is_one());

let b = dec256!(10e-1);
assert!(!b.is_one());
Source

pub const fn is_positive(&self) -> bool

Return true if this value is positive, including +0.0, +Infinity and NaN, and false otherwise.

§Examples
use fastnum::*;

let d = dec256!(7.0);
let neg_zero = dec256!(-0.0);
let neg_d = dec256!(-7.0);

assert!(d.is_positive());
assert!(D256::ZERO.is_positive());
assert!(D256::INFINITY.is_positive());
assert!(D256::NAN.is_positive());

assert!(!neg_d.is_positive());
assert!(!neg_zero.is_positive());
assert!(!D256::NEG_INFINITY.is_positive());
Source

pub const fn is_negative(&self) -> bool

Return true if this value is negative, including -0.0 and -Infinity and false otherwise.

§Examples
use fastnum::*;

let d = dec256!(7.0);
let neg_zero = dec256!(-0.0);
let neg_d = dec256!(-7.0);

assert!(neg_d.is_negative());
assert!(neg_zero.is_negative());
assert!(D256::NEG_INFINITY.is_negative());

assert!(!d.is_negative());
assert!(!D256::ZERO.is_negative());
assert!(!D256::INFINITY.is_negative());
assert!(!D256::NAN.is_negative());
Source

pub const fn with_ctx(self, ctx: Context) -> Self

Apply new Context to the given decimal number.

Returns a copy of the value with the provided context applied.

This method updates the operational context (including the rounding mode and other contextual parameters) used by subsequent operations that may round or clamp the value (e.g., add, sub, mul, div, round, rescale, quantize, etc.).

Important:

  • The change is local to the returned value and does not affect other values.
  • If you ignore the returned value, the context update is lost.
  • If the value currently carries extra precision, that extra precision is reconciled immediately with the new context: it is rounded using the context’s rounding mode (and may be clamped as dictated by the context).
  • If the current value already has signaling flags set (e.g., INEXACT and the new context enables traps for those signals, applying this method may trigger the corresponding traps immediately, which can result in a panic (depending on the build/configuration).
§Panics:
§debug mode

This method will panic if

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

let ctx = decimal::Context::default().without_traps();
let a = dec256!(1).with_ctx(ctx);
let b = dec256!(0).with_ctx(ctx);

// No panic! We can divide by zero!
let c = a / b;
assert!(c.is_infinite());
assert!(c.is_op_div_by_zero());

See also:

Source

pub const fn with_rounding_mode(self, rm: RoundingMode) -> Self

Apply new RoundingMode to the given decimal number.

Returns a copy of the value with an updated rounding mode in its context.

This method generally does not immediately change the mathematical value; it only sets the rounding rule that will be used by subsequent operations that may round (e.g., add, sub, mul, div, round, rescale, quantize, conversions, etc.).

Important:

  • The change is local to the returned value and does not affect other values.
  • If you ignore the returned value, the rounding mode update is lost.
  • If the value currently carries extra precision, that extra precision is rounded using the newly provided rounding mode at the moment this method is applied. This ensures internal consistency of the stored representation with the new rounding rule.
§Panics:
§debug mode

This method will panic if possible extra precision rounding operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

let a = dec256!(1).with_rounding_mode(decimal::RoundingMode::No);
let b = dec256!(3).with_rounding_mode(decimal::RoundingMode::No);
let c = dec256!(6).with_rounding_mode(decimal::RoundingMode::No);

assert_eq!(((a / b) * c).with_rounding_mode(decimal::RoundingMode::HalfUp), dec256!(2));

See also:

Source

pub const fn neg(self) -> Self

Invert the sign of the given decimal.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(+1.0).neg(), dec256!(-1.0));
assert_eq!(dec256!(1.0).neg(), dec256!(-1.0));
assert_eq!(dec256!(-1.0).neg(), dec256!(1.0));
Source

pub const fn abs(self) -> Self

Get the absolute value of the decimal (non-negative sign).

§Examples
use fastnum::dec256;

assert_eq!(dec256!(1.0).abs(), dec256!(1.0));
assert_eq!(dec256!(-1.0).abs(), dec256!(1.0));
Source

pub const fn unsigned_abs(self) -> UnsignedDecimal<N>

Get the absolute value of the decimal (non-negative sign) as UnsignedDecimal.

§Examples
use fastnum::{dec256, udec256};

assert_eq!(dec256!(1.0).unsigned_abs(), udec256!(1.0));
assert_eq!(dec256!(-1.0).unsigned_abs(), udec256!(1.0));
Source

pub const fn quantum(exp: i32, ctx: Context) -> Self

The quantum of a finite number is given by: 1 × 10exp. This is the value of a unit in the least significant position of the coefficient of a finite number.

§Examples
use fastnum::{D256, dec256, decimal::Context};

let ctx = Context::default();

assert_eq!(D256::quantum(0, ctx), dec256!(1));
assert_eq!(D256::quantum(-0, ctx), dec256!(1));
assert_eq!(D256::quantum(-3, ctx), dec256!(0.001));
assert_eq!(D256::quantum(3, ctx), dec256!(1000));
Source

pub const fn signum(&self) -> Self

Returns a number that represents the sign of self.

use fastnum::{D256, dec256};

let d = dec256!(3.5);

assert_eq!(d.signum(), dec256!(1.0));
assert_eq!(D256::NEG_INFINITY.signum(), dec256!(-1.0));

assert!(D256::NAN.signum().is_nan());
Source

pub const fn reduce(self) -> Self

Reduces a decimal number to its shortest (coefficient) form shifting all significant trailing zeros into the exponent.

§Examples
use fastnum::*;

let a = dec256!(-1234500);
assert_eq!(a.digits(), u256!(1234500));
assert_eq!(a.fractional_digits_count(), 0);

let b = a.reduce();
assert_eq!(b.digits(), u256!(12345));
assert_eq!(b.fractional_digits_count(), -2);
Source

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

Tests for self and other values to be equal, and is used by == operator.

Source

pub const fn ne(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by == operator.

Source

pub const fn max(self, other: Self) -> Self

Compares and returns the maximum of two signed decimal values.

Returns the second argument if the comparison determines them to be equal.

§Examples
use fastnum::{dec256};

assert_eq!(dec256!(1).max(dec256!(2)), dec256!(2));
assert_eq!(dec256!(2).max(dec256!(2)), dec256!(2));
Source

pub const fn min(self, other: Self) -> Self

Compares and returns the minimum of two signed decimal values.

Returns the first argument if the comparison determines them to be equal.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(1).min(dec256!(2)), dec256!(1));
assert_eq!(dec256!(2).min(dec256!(2)), dec256!(2));
Source

pub const fn clamp(self, min: Self, max: Self) -> Self

Restrict a signed decimal value to a certain interval.

Returns max if self is greater than max, and min if self is less than min. Otherwise, this returns self.

§Panics

Panics if min > max.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(-3).clamp(dec256!(-2), dec256!(1)), dec256!(-2));
assert_eq!(dec256!(0).clamp(dec256!(-2), dec256!(1)), dec256!(0));
assert_eq!(dec256!(2).clamp(dec256!(-2), dec256!(1)), dec256!(1));
Source

pub const fn abs_sub(self, other: Self) -> Self

The positive difference of two decimal numbers.

§Examples
  • If self <= other: 0:0
  • Else: self - other
use fastnum::dec256;

assert_eq!(dec256!(1).abs_sub(dec256!(3)), dec256!(0));
assert_eq!(dec256!(3).abs_sub(dec256!(1)), dec256!(2));
Source

pub const fn lt(&self, other: &Self) -> bool

Tests signed decimal self less than other and is used by the < operator.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(1.0).lt(&dec256!(1.0)), false);
assert_eq!(dec256!(1.0).lt(&dec256!(2.0)), true);
assert_eq!(dec256!(2.0).lt(&dec256!(1.0)), false);
Source

pub const fn le(&self, other: &Self) -> bool

Tests signed decimal self less than or equal to other and is used by the <= operator.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(1.0).le(&dec256!(1.0)), true);
assert_eq!(dec256!(1.0).le(&dec256!(2.0)), true);
assert_eq!(dec256!(2.0).le(&dec256!(1.0)), false);
Source

pub const fn gt(&self, other: &Self) -> bool

Tests signed decimal self greater than other and is used by the > operator.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(1.0).gt(&dec256!(1.0)), false);
assert_eq!(dec256!(1.0).gt(&dec256!(2.0)), false);
assert_eq!(dec256!(2.0).gt(&dec256!(1.0)), true);
Source

pub const fn ge(&self, other: &Self) -> bool

Tests signed decimal self greater than or equal to other and is used by the >= operator.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(1.0).ge(&dec256!(1.0)), true);
assert_eq!(dec256!(1.0).ge(&dec256!(2.0)), false);
assert_eq!(dec256!(2.0).ge(&dec256!(1.0)), true);
Source

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

This method returns an Ordering between self and other.

By convention, self.cmp(&other) returns the ordering matching the expression self <operator> other if true.

§Examples
use fastnum::dec256;
use std::cmp::Ordering;

assert_eq!(dec256!(5).cmp(&dec256!(10)), Ordering::Less);
assert_eq!(dec256!(10).cmp(&dec256!(5)), Ordering::Greater);
assert_eq!(dec256!(5).cmp(&dec256!(5)), Ordering::Equal);
Source

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

Calculates self + rhs.

Is internally used by the + operator.

§Panics:
§debug mode

This method will panic if addition operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

let a = D256::ONE;
let b = D256::TWO;

let c = a + b;
assert_eq!(c, dec256!(3));

Panics if overflowed:

use fastnum::*;

let a = D256::MAX;
let b = D256::MAX;

let c = a + b;

See more about add and subtract.

Source

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

Calculates selfrhs.

Is internally used by the - operator.

§Panics:
§debug mode

This method will panic if subtract operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

let a = D256::ONE;
let b = D256::TWO;

let c = a - b;
assert_eq!(c, dec256!(-1));

Panics if overflowed:

use fastnum::*;

let a = D256::MAX;
let b = -D256::MAX;

let c = a - b;

See more about add and subtract.

Source

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

Calculates self × rhs.

Is internally used by the * operator.

§Panics:
§debug mode

This method will panic if multiplication operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

let a = D256::FIVE;
let b = D256::TWO;

let c = a * b;
assert_eq!(c, dec256!(10));

Panics if overflowed:

use fastnum::*;

let a = D256::MAX;
let b = D256::MAX;

let c = a * b;

See more about multiplication.

Source

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

Calculates self ÷ rhs.

Is internally used by the / operator.

§Panics:
§debug mode

This method will panic if divide operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

let a = D256::FIVE;
let b = D256::TWO;

let c = -a / b;
assert_eq!(c, dec256!(-2.5));

Panics if divided by zero:

use fastnum::{dec256, D256};

let a = D256::ONE;
let b = D256::ZERO;

let c = a / b;

See more about division.

Source

pub const fn rem(self, rhs: Self) -> Self

Calculates self % rhs.

Is internally used by the % operator.

§Panics:
§debug mode

This method will panic if reminder operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

let a = D256::FIVE;
let b = D256::TWO;

let c = a % b;
assert_eq!(c, dec256!(1));
Source

pub const fn pow(self, n: Self) -> Self

Raise a decimal number to decimal power.

Using this function is generally slower than using powi for integer powers or sqrt method for 1/2 exponent.

§Precision

Since the result of power operation is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if power operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec256!(4).pow(dec256!(0.5)), dec256!(2));
assert_eq!(dec256!(8).pow(dec256!(1) / dec256!(3)), dec256!(2));

See more about the power operation.

Source

pub const fn powi(self, n: i32) -> Self

Raise a decimal number to an integer power.

Using this function is generally faster than using pow

§Panics:
§debug mode

This method will panic if power operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec256!(2).powi(3), dec256!(8));
assert_eq!(dec256!(9).powi(2), dec256!(81));
assert_eq!(dec256!(1).powi(-2), dec256!(1));
assert_eq!(dec256!(10).powi(20), dec256!(1e20));
assert_eq!(dec256!(4).powi(-2), dec256!(0.0625));

See more about the power operation.

Source

pub const fn sqrt(self) -> Self

Take the square root of the decimal number using Heron’s method, a special case of Newton’s method.

Returns NaN if self is a negative number other than -0.0.

§Precision

Since the result of square root operation is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if square root operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(4).sqrt(), dec128!(2));
assert_eq!(dec128!(1).sqrt(), dec128!(1));
assert_eq!(dec128!(16).sqrt(), dec128!(4));
assert_eq!(dec128!(2).sqrt(), D128::SQRT_2);

See more about the square-root operation.

Source

pub const fn cbrt(self) -> Self

Take the cubic root of a decimal number using Newton’s method.

§Precision

Since the result of cubic root operation is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if cubic root operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(8).cbrt(), dec128!(2));

See more about the N-th root operation.

Source

pub const fn nth_root(self, n: u32) -> Self

Take the N-th root of the decimal number using Newton’s method.

§Precision

Since the result of N-th root operation is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if N-th root operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(16).nth_root(4), dec128!(2));

See more about the N-th root operation.

Source

pub const fn exp(self) -> Self

Returns eself, (the exponential function).

§Precision

Since the result of exponential function is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if exponent calculation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(1).exp(), D128::E);

See more about the exponential function.

Source

pub const fn exp_m1(self) -> Self

Returns eself – 1.

§Precision

Since the result of exponential function is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if exponent calculation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::{*, decimal::RoundingMode::*};

// For exact result we need to use extra precision digits and no-rounding mode to keep precision between `.ln()` and `exp()` calls.
// Than we can use default rounding mode for round extra digits.
assert_eq!(dec128!(7.0).with_rounding_mode(No).ln().exp_m1().with_rounding_mode(HalfUp), D128::SIX);

See more about the exponential function.

Source

pub const fn exp2(self) -> Self

Returns 2self, (the binary exponential function).

§Precision

Since the result of binary exponential function is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if binary exponential function performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(0).exp2(), dec128!(1));
assert_eq!(dec128!(1).exp2(), dec128!(2));
assert_eq!(dec128!(2).exp2(), dec128!(4));
assert_eq!(dec128!(3).exp2(), dec128!(8));

See more about the binary exponential function.

Source

pub const fn ln(self) -> Self

Returns the natural logarithm of the decimal number.

§Precision

Since the result of natural logarithm is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if logarithm operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

assert_eq!(dec256!(2).ln(), D256::LN_2);
assert_eq!(D256::E.ln(), D256::ONE);

See also:

Source

pub const fn ln_1p(self) -> Self

Returns natural logarithm ln(1 + self) more accurately than if the operations were performed separately.

§Precision

Since the result of natural logarithm is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if logarithm operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

assert_eq!((D256::E - dec256!(1)).ln_1p(), dec256!(1));

See also:

Source

pub const fn log(self, base: Self) -> Self

Returns the logarithm of the decimal number with respect to the given arbitrary base.

§Precision

Since the result of logarithm is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if logarithm operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

assert_eq!(dec256!(64).log(dec256!(2)), dec256!(6));
assert_eq!(dec256!(27).log(dec256!(3)), dec256!(3));
assert_eq!(dec256!(15625).log(dec256!(5)), dec256!(6));

See also:

Source

pub const fn log2(self) -> Self

Returns the binary logarithm of the given decimal number.

§Precision

Since the result of logarithm is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if logarithm operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

assert_eq!(dec256!(64).log2(), dec256!(6));
assert_eq!(dec256!(32).log2(), dec256!(5));
assert_eq!(dec256!(1024).log2(), dec256!(10));
assert_eq!(dec256!(0.5).log2(), dec256!(-1));
assert_eq!(dec256!(0.25).log2(), dec256!(-2));
assert_eq!(dec256!(10).log2(), D256::LOG2_10);

See also:

Source

pub const fn log10(self) -> Self

Returns the decimal logarithm of the given decimal number.

§Precision

Since the result of logarithm is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if logarithm operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

assert_eq!(dec256!(100).log10(), dec256!(2));
assert_eq!(dec256!(1000).log10(), dec256!(3));
assert_eq!(dec256!(0.1).log10(), dec256!(-1));
assert_eq!(dec256!(0.01).log10(), dec256!(-2));
assert_eq!(dec256!(2).log10(), D256::LOG10_2);

See also:

Source

pub const fn hypot(self, other: Self) -> Self

Calculate the length of the hypotenuse of a right-angle triangle given legs of length x and y.

§Panics:
§debug mode

This method will panic if hypotenuse calculate operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::dec256;

let x = dec256!(2);
let y = dec256!(3);

// sqrt(x^2 + y^2)
assert_eq!(x.hypot(y), (x.powi(2) + y.powi(2)).sqrt());
Source

pub const fn mul_add(self, a: Self, b: Self) -> Self

Fused multiply-add. Computes (self * a) + b with only one rounding error, yielding a more accurate result than an unfused multiply-add.

§Panics:
§debug mode

This method will panic if multiply-add operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(10.0).mul_add(dec128!(4.0), dec128!(60)), dec128!(100));

See more about the fused multiply-add function.

Source

pub const fn round(self, digits: i16) -> Self

Returns the given decimal number rounded to digits precision after the decimal point, using RoundingMode from it Context.

§Panics:
§debug mode

This method will panic if round operation (up-scale or down-scale) performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples
use fastnum::{*, decimal::{*, RoundingMode::*}};

let n = dec256!(129.41675);

// Default rounding mode is `HalfUp`
assert_eq!(n.round(2),  dec256!(129.42));

assert_eq!(n.with_rounding_mode(Up).round(2), dec256!(129.42));
assert_eq!(n.with_rounding_mode(Down).round(-1), dec256!(120));
assert_eq!(n.with_rounding_mode(HalfEven).round(4), dec256!(129.4168));

See also:

Source

pub const fn trunc(self) -> Self

Truncates the decimal number to integral with no fractional portion.

This is a true truncation whereby no rounding is performed. This operation is equivalent to Self::rescale or Self::trunc_with_scale with scale set to 0.

§Performance

This operation is typically much faster than Self::rescale

§Panics:
§debug mode

This method will panic if truncate operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

assert_eq!(dec256!(3.141).trunc(), dec256!(3));
assert_eq!(dec256!(2.9).trunc(), dec256!(2));
assert_eq!(dec256!(-1.98765).trunc(), dec256!(-1));

let ctx = decimal::Context::default().without_traps();

assert!(D256::INFINITY.with_ctx(ctx).trunc().is_nan());
assert!(D256::NEG_INFINITY.with_ctx(ctx).trunc().is_nan());
assert!(D256::NAN.with_ctx(ctx).trunc().is_nan());

See also:

Source

pub const fn trunc_with_scale(self, scale: i16) -> Self

Truncates the decimal number to the given number of digits after the decimal point.

This is a true truncation whereby no rounding is performed. This operation is equivalent to Self::rescale.

§Performance

This operation is typically much faster than Self::rescale

§Panics:
§debug mode

This method will panic if truncate operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D256 is used here.

use fastnum::*;

assert_eq!(dec256!(3.141592).trunc_with_scale(2), dec256!(3.14));
assert_eq!(dec256!(3.141592).trunc_with_scale(3), dec256!(3.141));
assert_eq!(dec256!(3.141592).trunc_with_scale(4), dec256!(3.1415));
assert_eq!(dec256!(3.141592).trunc_with_scale(5), dec256!(3.14159));
assert_eq!(dec256!(3.141592).trunc_with_scale(6), dec256!(3.141592));
assert_eq!(dec256!(-1.98765).trunc_with_scale(1), dec256!(-1.9));

let ctx = decimal::Context::default().without_traps();

assert!(D256::INFINITY.with_ctx(ctx).trunc_with_scale(1).is_nan());
assert!(D256::NEG_INFINITY.with_ctx(ctx).trunc_with_scale(1).is_nan());
assert!(D256::NAN.with_ctx(ctx).trunc_with_scale(1).is_nan());

See also:

Source

pub const fn floor(self) -> Self

Returns the largest integer less than or equal to a number.

§Examples
use fastnum::*;

assert_eq!(dec256!(3.99).floor(), dec256!(3));
assert_eq!(dec256!(3.0).floor(), dec256!(3));
assert_eq!(dec256!(3.01).floor(), dec256!(3));
assert_eq!(dec256!(3.5).floor(), dec256!(3));
assert_eq!(dec256!(4.0).floor(), dec256!(4));

assert_eq!(dec256!(-3.01).floor(), dec256!(-4));
assert_eq!(dec256!(-3.1).floor(), dec256!(-4));
assert_eq!(dec256!(-3.5).floor(), dec256!(-4));
assert_eq!(dec256!(-4.0).floor(), dec256!(-4));
Source

pub const fn ceil(self) -> Self

Finds the nearest integer greater than or equal to x.

§Examples
use fastnum::*;

assert_eq!(dec256!(3.01).ceil(), dec256!(4));
assert_eq!(dec256!(3.99).ceil(), dec256!(4));
assert_eq!(dec256!(4.0).ceil(), dec256!(4));
assert_eq!(dec256!(1.0001).ceil(), dec256!(2));
assert_eq!(dec256!(1.00001).ceil(), dec256!(2));
assert_eq!(dec256!(1.000001).ceil(), dec256!(2));
assert_eq!(dec256!(1.00000000000001).ceil(), dec256!(2));

assert_eq!(dec256!(-3.01).ceil(), dec256!(-3));
assert_eq!(dec256!(-3.5).ceil(), dec256!(-3));
assert_eq!(dec256!(-4.0).ceil(), dec256!(-4));
Source

pub const fn rescale(self, new_scale: i16) -> Self

Returns the given decimal number re-scaled to digits precision after the decimal point.

§Panics:
§debug mode

This method will panic if rescale operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples
use fastnum::{*, decimal::*};

assert_eq!(dec256!(2.17).rescale(3), dec256!(2.170));
assert_eq!(dec256!(2.17).rescale(2), dec256!(2.17));
assert_eq!(dec256!(2.17).rescale(1), dec256!(2.2));
assert_eq!(dec256!(2.17).rescale(0), dec256!(2));
assert_eq!(dec256!(2.17).rescale(-1), dec256!(0));

let ctx = Context::default().without_traps();

assert!(D256::INFINITY.with_ctx(ctx).rescale(2).is_nan());
assert!(D256::NEG_INFINITY.with_ctx(ctx).rescale(2).is_nan());
assert!(D256::NAN.with_ctx(ctx).rescale(1).is_nan());

See also:

Source

pub const fn quantize(self, other: Self) -> Self

Returns a value equal to self (rounded), having the exponent of other.

§Panics:
§debug mode

This method will panic if quantize operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples
use fastnum::{*, decimal::*};

let ctx = Context::default().without_traps();

assert_eq!(dec256!(2.17).quantize(dec256!(0.001)), dec256!(2.170));
assert_eq!(dec256!(2.17).quantize(dec256!(0.01)), dec256!(2.17));
assert_eq!(dec256!(2.17).quantize(dec256!(0.1)), dec256!(2.2));
assert_eq!(dec256!(2.17).quantize(dec256!(1e+0)), dec256!(2));
assert_eq!(dec256!(2.17).quantize(dec256!(1e+1)), dec256!(0));

assert_eq!(D256::NEG_INFINITY.quantize(D256::INFINITY), D256::NEG_INFINITY);

assert!(dec256!(2).with_ctx(ctx).quantize(D256::INFINITY).is_nan());

assert_eq!(dec256!(-0.1).quantize(dec256!(1)), dec256!(-0));
assert_eq!(dec256!(-0).quantize(dec256!(1e+5)), dec256!(-0E+5));

assert!(dec128!(0.34028).with_ctx(ctx).quantize(dec128!(1e-32765)).is_nan());
assert!(dec128!(-0.34028).with_ctx(ctx).quantize(dec128!(1e-32765)).is_nan());

assert_eq!(dec256!(217).quantize(dec256!(1e-1)), dec256!(217.0));
assert_eq!(dec256!(217).quantize(dec256!(1e+0)), dec256!(217));
assert_eq!(dec256!(217).quantize(dec256!(1e+1)), dec256!(2.2E+2));
assert_eq!(dec256!(217).quantize(dec256!(1e+2)), dec256!(2E+2));

See also:

Source

pub const fn is_ok(&self) -> bool

Returns:

Source

pub const fn ok(self) -> Option<Self>

Returns:

Source

pub const fn recip(self) -> Self

Takes the reciprocal (inverse) of a number, 1/x.

§Precision

Since the result of reciprocal is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if reciprocal operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples
use fastnum::*;

assert_eq!(dec256!(2).recip(), dec256!(0.5));
Source

pub const fn to_degrees(self) -> Self

Converts radians to degrees.

§Panics:
§debug mode

This method will panic if conversion performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples
use fastnum::*;

assert_eq!(D128::PI.to_degrees(), dec128!(180));
assert_eq!(D128::TAU.to_degrees(), dec128!(360));
Source

pub const fn to_radians(self) -> Self

Converts degrees to radians.

§Panics:
§debug mode

This method will panic if conversion performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples
use fastnum::*;

assert_eq!(dec128!(180).to_radians(), D128::PI);
assert_eq!(dec128!(360).to_radians(), D128::TAU);
Source

pub fn to_scientific_notation(&self) -> String

Create a string of this decimal in scientific notation.

§Examples
use fastnum::dec256;

let n = dec256!(-12345678);
assert_eq!(&n.to_scientific_notation(), "-1.2345678e7");
Source

pub fn to_engineering_notation(&self) -> String

Create a string of this decimal in engineering notation.

Engineering notation is scientific notation with the exponent coerced to a multiple of three

§Examples
use fastnum::dec256;

let n = dec256!(-12345678);
assert_eq!(&n.to_engineering_notation(), "-12.345678e6");
Source

pub const fn transmute<const M: usize>(self) -> Decimal<M>

👎Deprecated since 0.5.0

Deprecated, use resize instead.

Source

pub const fn resize<const M: usize>(self) -> Decimal<M>

Safety resizes the underlying decimal to use M limbs while preserving the numeric value when possible.

This operation can either widen or narrow the internal representation:

  • Widening (M >= N) is lossless: the value is preserved.
  • Narrowing (M < N) may reduce available capacity. In this case the value is rounded according to the current Context and corresponding status flags are set.

Behavior details:

  • Rounding: extra precision is rounded using the active RoundingMode from the current context.
  • Signals: status flags such as Inexact, Rounded, Clamped, Overflow, or Underflow may be raised depending on the operation outcome and context limits.

Note: lossless, no-rounding conversions.

If you need to change width without any rounding:

  • Use crate::Cast for guaranteed-lossless widening (value-preserving by definition).

  • Use crate::TryCast for potential narrowing without rounding; it returns an error if the value does not fit into the target width, thus guaranteeing no silent rounding or truncation.

§Performance

This operation is typically much slower than crate::Cast and crate::TryCast transformations.

§Panics:
§debug mode

This method will panic if resize operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Please note that this example is shared between decimal types. Which explains why D64 is used here.

§Lossless widening:
use fastnum::*;

let x = dec64!(123.45);

// Increase internal width from 2 to 4 limbs — value is preserved.
let y: D128 = x.resize();
assert_eq!(y, dec128!(123.45));
assert!(y.is_op_ok());
§Narrowing with possible rounding:
use fastnum::*;

let x = dec128!(1.8446744073709551616);

// Reduce width; value may be rounded according to context.
let y: D64 = x.resize();
// Rounding/precision-loss indicators may be set, depending on capacity and context:
assert_eq!(y, dec64!(1.844674407370955162));
assert!(y.is_op_inexact() && y.is_op_rounded());

See also:

Source

pub const fn is_even(&self) -> bool

Returns true if the decimal number is even.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(3).is_even(), false);
assert_eq!(dec256!(4).is_even(), true);
Source

pub const fn is_odd(&self) -> bool

Returns true if the decimal number is odd.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(3).is_odd(), true);
assert_eq!(dec256!(4).is_odd(), false);
Source

pub const fn is_integral(&self) -> bool

Returns true if the decimal number is integral.

§Examples
use fastnum::dec256;

assert_eq!(dec256!(3.3).is_integral(), false);
assert_eq!(dec256!(4).is_integral(), true);
assert_eq!(dec256!(1.0).is_integral(), true);
assert_eq!(dec256!(10.0).is_integral(), true);
Source

pub const fn sin(self) -> Self

Computes sin(self) (trigonometric sine of decimal number in radians).

§Precision

Since the result of trigonometric sine is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if trigonometric sine operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(D128::FRAC_PI_2.sin(), dec128!(1));

See more about the trigonometric functions.

Source

pub const fn cos(self) -> Self

Computes cos(self) (trigonometric cosine of decimal number in radians).

§Precision

Since the result of trigonometric cosine is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if trigonometric cosine operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(D128::TAU.cos(), dec128!(1));

See more about the trigonometric functions.

Source

pub const fn tan(self) -> Self

Computes tan(self) (trigonometric tangent of decimal number in radians).

§Precision

Since the result of trigonometric tangent is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if trigonometric tangent operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(D128::FRAC_PI_4.tan(), dec128!(1));

See more about the trigonometric functions.

Source

pub const fn asin(self) -> Self

Computes arcsin(self) (trigonometric arcsine of decimal number).

Return value is in radians in the range [-π/2, π/2] or NaN if the number is outside the range [-1, 1].

§Precision

Since the result of trigonometric arcsine is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if trigonometric arcsine operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(D128::FRAC_PI_2.sin().asin(), D128::FRAC_PI_2);

See more about the trigonometric functions.

Source

pub const fn acos(self) -> Self

Computes arccos(self) (trigonometric arccosine of decimal number).

Return value is in radians in the range [0, π] or NaN if the number is outside the range [-1, 1].

§Precision

Since the result of trigonometric arccosine is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if trigonometric arccosine operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec256!(1).acos(), dec256!(0));

See more about the trigonometric functions.

Source

pub const fn atan(self) -> Self

Computes arctan(self) (trigonometric arctangent of decimal number).

Return value is in radians in the range [-π/2, π/2].

§Precision

Since the result of trigonometric arctangent is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if trigonometric arctangent operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(D128::ZERO.atan(), D128::ZERO);
assert_eq!(D128::ONE.atan(), D128::FRAC_PI_4);
assert_eq!(D128::ONE.neg().atan(), D128::FRAC_PI_4.neg());

See more about the trigonometric functions.

Source

pub const fn atan2(self, other: Self) -> Self

Computes the four quadrant arctangent of self (y) and other (x).

  • x = 0, y = 0: 0
  • x >= 0: arctan(y/x) -> [-π/2, π/2]
  • y >= 0: arctan(y/x) + π -> (pi/2, π]
  • y < 0: arctan(y/x) - π -> (-π, -π/2)
§Precision

Since the result of trigonometric 2-argument arctangent is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if trigonometric 2-argument arctangent operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(-3.0).atan2(dec128!(3.0)), D128::FRAC_PI_4.neg());
assert_eq!(dec128!(3.0).atan2(dec128!(-3.0)), D128::FRAC_PI_4 * D128::THREE);

See more about the trigonometric functions.

Source

pub const fn sin_cos(self) -> (Self, Self)

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).

§Precision

Since the result of trigonometric sine and cosine function is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if trigonometric sine and cosine computation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(D128::FRAC_PI_2.sin_cos(), (dec128!(1), dec128!(0)));

See more about the trigonometric functions.

Source

pub const fn sinh(self) -> Self

Computes sinh(self) (hyperbolic sine of decimal number).

§Precision

Since the result of hyperbolic sine is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if hyperbolic sine operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(1).sinh(), (D128::E * D128::E - dec128!(1.0)) / (dec128!(2.0) * D128::E));

See more about the trigonometric functions.

Source

pub const fn cosh(self) -> Self

Computes cosh(self) (hyperbolic cosine of decimal number).

§Precision

Since the result of hyperbolic cosine is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if hyperbolic cosine operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec256!(1).cosh(), (D256::E * D256::E + dec256!(1.0)) / (dec256!(2.0) * D256::E));

See more about the trigonometric functions.

Source

pub const fn tanh(self) -> Self

Computes tanh(self) (hyperbolic tangent of decimal number).

§Precision

Since the result of hyperbolic tangent is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if hyperbolic tangent operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

let e2 = D128::E * D128::E;
assert_eq!(dec128!(1).tanh(), (e2 - dec128!(1.0)) / (e2 + dec128!(1.0)));

See more about the trigonometric functions.

Source

pub const fn asinh(self) -> Self

Computes arsinh(self) (inverse hyperbolic sine of decimal number).

§Precision

Since the result of inverse hyperbolic sine is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if inverse hyperbolic sine operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(1).sinh().asinh(), dec128!(1));

See more about the trigonometric functions.

Source

pub const fn acosh(self) -> Self

Computes arcosh(self) (inverse hyperbolic cosine of decimal number).

§Precision

Since the result of inverse hyperbolic cosine is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if inverse hyperbolic cosine operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(dec128!(1).cosh().acosh(), dec128!(1));

See more about the trigonometric functions.

Source

pub const fn atanh(self) -> Self

Computes artanh(self) (inverse hyperbolic tangent of decimal number).

§Precision

Since the result of inverse hyperbolic tangent is irrational number, it can usually only be computed to some finite precision from a series of increasingly accurate approximations.

The result of this operation is mostly inexact and raises OP_INEXACT signal.

§Panics:
§debug mode

This method will panic if inverse hyperbolic tangent operation performs with some Exceptional condition and corresponding Signals in the Context is trapped by trap-enabler.

§release mode

In release mode panic will not occur and result can be one of Special values(NaN or ±Infinity).

§Examples

Basic usage:

use fastnum::*;

assert_eq!(D256::ZERO.tanh().atanh(), D256::ZERO);

See more about the trigonometric functions.

Source

pub const fn from_unsigned(ud: UnsignedDecimal<N>) -> Self

Converts from UnsignedDecimal to a signed Decimal number.

§Examples
use fastnum::*;

let d = udec256!(1.2345);

assert_eq!(D256::from_unsigned(d), dec256!(1.2345));
Source

pub const fn try_to_unsigned(self) -> Result<UnsignedDecimal<N>, DecimalError>

Try converts from Decimal to UnsignedDecimal.

§Examples
use fastnum::*;

assert_eq!(dec256!(1.2345).try_to_unsigned(), Ok(udec256!(1.2345)));
assert!(dec256!(-1.2345).try_to_unsigned().is_err());

Trait Implementations§

Source§

impl<const N: usize> Add<Decimal<N>> for f32

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for f64

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for i128

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for i16

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for i32

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for i64

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for i8

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for isize

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for u128

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for u16

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for u32

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for u64

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for u8

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<Decimal<N>> for usize

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<f32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<f64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i128) -> Decimal<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<i8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<isize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u128) -> Decimal<N>

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<u8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add<usize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> Add for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<const N: usize> AddAssign<f32> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: f32)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<f64> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: f64)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<i128> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: i128)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<i16> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: i16)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<i32> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: i32)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<i64> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: i64)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<i8> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: i8)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<isize> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: isize)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<u128> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: u128)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<u16> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: u16)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<u32> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: u32)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<u64> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: u64)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<u8> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: u8)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign<usize> for Decimal<N>

Source§

fn add_assign(&mut self, rhs: usize)

Performs the += operation. Read more
Source§

impl<const N: usize> AddAssign for Decimal<N>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<const N: usize, const M: usize> Cast<Decimal<N>> for Decimal<N>
where Dimension<N, M>: Widen,

Source§

fn cast(self) -> Decimal<N>

Performs an infallible, value-preserving conversion. Read more
Source§

impl<const N: usize, const M: usize> Cast<Decimal<N>> for UnsignedDecimal<N>
where Dimension<N, M>: Widen,

Source§

fn cast(self) -> Decimal<N>

Performs an infallible, value-preserving conversion. Read more
Source§

impl<const N: usize> Cast<Decimal<N>> for UnsignedDecimal<N>

Source§

fn cast(self) -> Decimal<N>

Performs an infallible, value-preserving conversion. Read more
Source§

impl<const N: usize> Clone for Decimal<N>

Source§

fn clone(&self) -> Decimal<N>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for Decimal<N>

Source§

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

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

impl<const N: usize> Default for Decimal<N>

Source§

fn default() -> Self

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

impl<'de, const N: usize> Deserialize<'de> for Decimal<N>

Source§

fn deserialize<D>(d: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<const N: usize> Display for Decimal<N>

Source§

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

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

impl<const N: usize> Div<Decimal<N>> for f32

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for f64

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for i128

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for i16

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for i32

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for i64

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for i8

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for isize

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for u128

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for u16

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for u32

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for u64

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for u8

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<Decimal<N>> for usize

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<f32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<f64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<i128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i128) -> Decimal<N>

Performs the / operation. Read more
Source§

impl<const N: usize> Div<i16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<i32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<i64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<i8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<isize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<u128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u128) -> Decimal<N>

Performs the / operation. Read more
Source§

impl<const N: usize> Div<u16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<u32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<u64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<u8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div<usize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> Div for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<const N: usize> DivAssign<f32> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<f64> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<i128> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: i128)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<i16> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: i16)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<i32> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<i64> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: i64)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<i8> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: i8)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<isize> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: isize)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<u128> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: u128)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<u16> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: u16)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<u32> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<u64> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: u64)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<u8> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: u8)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign<usize> for Decimal<N>

Source§

fn div_assign(&mut self, rhs: usize)

Performs the /= operation. Read more
Source§

impl<const N: usize> DivAssign for Decimal<N>

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl<const N: usize> From<Decimal<N>> for f32

Source§

fn from(d: Decimal<N>) -> f32

Converts to this type from the input type.
Source§

impl<const N: usize> From<Decimal<N>> for f64

Source§

fn from(d: Decimal<N>) -> f64

Converts to this type from the input type.
Source§

impl<const N: usize> From<UnsignedDecimal<N>> for Decimal<N>

Source§

fn from(ud: UnsignedDecimal<N>) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<f32> for Decimal<N>

Source§

fn from(n: f32) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<f64> for Decimal<N>

Source§

fn from(n: f64) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<i16> for Decimal<N>

Source§

fn from(n: i16) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<i32> for Decimal<N>

Source§

fn from(n: i32) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<i64> for Decimal<N>

Source§

fn from(n: i64) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<i8> for Decimal<N>

Source§

fn from(n: i8) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<isize> for Decimal<N>

Source§

fn from(n: isize) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<u16> for Decimal<N>

Source§

fn from(n: u16) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<u32> for Decimal<N>

Source§

fn from(n: u32) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<u64> for Decimal<N>

Source§

fn from(n: u64) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<u8> for Decimal<N>

Source§

fn from(n: u8) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<usize> for Decimal<N>

Source§

fn from(n: usize) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> FromStr for Decimal<N>

Source§

type Err = ParseError

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

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

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

impl<const N: usize> Hash for Decimal<N>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<const N: usize> LowerExp for Decimal<N>

Source§

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

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

impl<const N: usize> Mul<Decimal<N>> for f32

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for f64

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for i128

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for i16

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for i32

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for i64

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for i8

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for isize

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for u128

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for u16

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for u32

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for u64

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for u8

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<Decimal<N>> for usize

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<f32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<f64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<i128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i128) -> Decimal<N>

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<i16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<i32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<i64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<i8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<isize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<u128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u128) -> Decimal<N>

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<u16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<u32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<u64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<u8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul<usize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> Mul for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<const N: usize> MulAssign<f32> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<f64> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<i128> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: i128)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<i16> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: i16)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<i32> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<i64> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: i64)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<i8> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: i8)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<isize> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: isize)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<u128> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: u128)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<u16> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: u16)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<u32> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<u64> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: u64)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<u8> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: u8)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign<usize> for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: usize)

Performs the *= operation. Read more
Source§

impl<const N: usize> MulAssign for Decimal<N>

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl<const N: usize> Neg for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<const N: usize> Ord for Decimal<N>

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl<const N: usize> PartialEq for Decimal<N>

Source§

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

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

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

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

impl<const N: usize> PartialOrd for Decimal<N>

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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<const N: usize> Rem<Decimal<N>> for f32

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for f64

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for i128

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for i16

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for i32

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for i64

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for i8

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for isize

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for u128

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for u16

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for u32

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for u64

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for u8

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<Decimal<N>> for usize

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<f32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<f64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<i128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i128) -> Decimal<N>

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<i16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<i32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<i64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<i8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<isize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<u128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u128) -> Decimal<N>

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<u16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<u32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<u64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<u8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem<usize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> Rem for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl<const N: usize> RemAssign<f32> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: f32)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<f64> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: f64)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<i128> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: i128)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<i16> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: i16)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<i32> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: i32)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<i64> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: i64)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<i8> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: i8)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<isize> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: isize)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<u128> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: u128)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<u16> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: u16)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<u32> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: u32)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<u64> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: u64)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<u8> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: u8)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign<usize> for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: usize)

Performs the %= operation. Read more
Source§

impl<const N: usize> RemAssign for Decimal<N>

Source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
Source§

impl<const N: usize> Serialize for Decimal<N>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for f32

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for f64

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for i128

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for i16

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for i32

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for i64

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for i8

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for isize

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for u128

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for u16

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for u32

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for u64

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for u8

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<Decimal<N>> for usize

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<f32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<f64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i128) -> Decimal<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<i8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<isize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u128> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u128) -> Decimal<N>

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u16> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u32> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u64> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<u8> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub<usize> for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> Sub for Decimal<N>

Source§

type Output = Decimal<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<const N: usize> SubAssign<f32> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: f32)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<f64> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: f64)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<i128> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: i128)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<i16> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: i16)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<i32> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: i32)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<i64> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: i64)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<i8> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: i8)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<isize> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: isize)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<u128> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: u128)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<u16> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: u16)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<u32> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: u32)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<u64> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: u64)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<u8> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: u8)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign<usize> for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: usize)

Performs the -= operation. Read more
Source§

impl<const N: usize> SubAssign for Decimal<N>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<const N: usize> Sum for Decimal<N>

Source§

fn sum<I: Iterator<Item = Decimal<N>>>(iter: I) -> Decimal<N>

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<const N: usize, const M: usize> TryCast<Decimal<N>> for Decimal<N>
where Dimension<N, M>: Narrow,

Source§

type Error = ParseError

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

fn try_cast(self) -> Result<Decimal<N>, Self::Error>

Attempts to convert self into T, returning an error on failure. Read more
Source§

impl<const N: usize, const M: usize> TryCast<Decimal<N>> for UnsignedDecimal<N>
where Dimension<N, M>: Narrow,

Source§

type Error = ParseError

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

fn try_cast(self) -> Result<Decimal<N>, Self::Error>

Attempts to convert self into T, returning an error on failure. Read more
Source§

impl<const N: usize, const M: usize> TryCast<UnsignedDecimal<N>> for Decimal<N>

Source§

type Error = ParseError

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

fn try_cast(self) -> Result<UnsignedDecimal<N>, Self::Error>

Attempts to convert self into T, returning an error on failure. Read more
Source§

impl<const N: usize> TryFrom<Decimal<N>> for UnsignedDecimal<N>

Source§

type Error = DecimalError

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

fn try_from(d: Decimal<N>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for i128

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<i128, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for i16

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<i16, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for i32

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<i32, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for i64

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<i64, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for i8

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<i8, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for isize

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<isize, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for u128

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<u128, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for u16

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<u16, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for u32

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<u32, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for u64

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<u64, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for u8

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<u8, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<Decimal<N>> for usize

Source§

type Error = ParseError

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

fn try_from(d: Decimal<N>) -> Result<usize, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<i128> for Decimal<N>

Source§

type Error = ParseError

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

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

Performs the conversion.
Source§

impl<const N: usize> TryFrom<u128> for Decimal<N>

Source§

type Error = ParseError

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

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

Performs the conversion.
Source§

impl<const N: usize> UpperExp for Decimal<N>

Source§

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

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

impl<const N: usize> Copy for Decimal<N>

Source§

impl<const N: usize> Eq for Decimal<N>

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Decimal<N>

§

impl<const N: usize> RefUnwindSafe for Decimal<N>

§

impl<const N: usize> Send for Decimal<N>

§

impl<const N: usize> Sync for Decimal<N>

§

impl<const N: usize> Unpin for Decimal<N>

§

impl<const N: usize> UnsafeUnpin for Decimal<N>

§

impl<const N: usize> UnwindSafe for Decimal<N>

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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,