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>
impl<const N: usize> Decimal<N>
Sourcepub const fn from_usize(n: usize) -> Self
pub const fn from_usize(n: usize) -> Self
Sourcepub const fn from_isize(n: isize) -> Self
pub const fn from_isize(n: isize) -> Self
Source§impl<const N: usize> Decimal<N>
impl<const N: usize> Decimal<N>
Sourcepub const NEG_INFINITY: Self
pub const NEG_INFINITY: Self
Negative infinity (−∞). More about ±Infinity.
Sourcepub const MIN: Self
pub const MIN: Self
The smallest value that can be represented by this decimal type - (2N - 1) × 1032’768.
Sourcepub const MIN_POSITIVE: Self
pub const MIN_POSITIVE: Self
The smallest positive, normalized value that this type can represent.
Sourcepub const EPSILON: Self
pub const EPSILON: Self
Machine epsilon value.
This is the difference between 1.0 and the next larger representable number.
Sourcepub const FRAC_2_SQRT_PI: Self
pub const FRAC_2_SQRT_PI: Self
2/sqrt(π).
Sourcepub const FRAC_1_SQRT_2: Self
pub const FRAC_1_SQRT_2: Self
1/sqrt(2).
Source§impl<const N: usize> Decimal<N>
impl<const N: usize> Decimal<N>
Sourcepub const fn from_parts(
digits: UInt<N>,
exp: i32,
sign: Sign,
ctx: Context,
) -> Self
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));Sourcepub const fn from_str(s: &str, ctx: Context) -> Result<Self, ParseError>
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)));Sourcepub const fn parse_str(s: &str, ctx: Context) -> Self
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());Sourcepub const fn digits(&self) -> UInt<N>
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));Sourcepub const fn digits_count(&self) -> usize
pub const fn digits_count(&self) -> usize
Return the count of digits in the non-scaled integer representation
Sourcepub const fn fractional_digits_count(&self) -> i16
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);Sourcepub const fn is_op_div_by_zero(&self) -> bool
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.
Sourcepub const fn is_op_overflow(&self) -> bool
pub const fn is_op_overflow(&self) -> bool
Return true if the argument has Signals::OP_OVERFLOW signal flag,
and false otherwise.
Sourcepub const fn is_op_underflow(&self) -> bool
pub const fn is_op_underflow(&self) -> bool
Return true if the argument has Signals::OP_UNDERFLOW signal flag,
and false otherwise.
Sourcepub const fn is_op_invalid(&self) -> bool
pub const fn is_op_invalid(&self) -> bool
Return true if the argument has Signals::OP_INVALID signal flag, and
false otherwise.
Sourcepub const fn is_op_subnormal(&self) -> bool
pub const fn is_op_subnormal(&self) -> bool
Return true if the argument has Signals::OP_SUBNORMAL signal flag,
and false otherwise.
Sourcepub const fn is_op_inexact(&self) -> bool
pub const fn is_op_inexact(&self) -> bool
Return true if the argument has Signals::OP_INEXACT signal flag, and
false otherwise.
Sourcepub const fn is_op_rounded(&self) -> bool
pub const fn is_op_rounded(&self) -> bool
Return true if the argument has Signals::OP_ROUNDED signal flag, and
false otherwise.
Sourcepub const fn is_op_clamped(&self) -> bool
pub const fn is_op_clamped(&self) -> bool
Return true if the argument has Signals::OP_CLAMPED signal flag, and
false otherwise.
Sourcepub const fn is_op_ok(&self) -> bool
pub const fn is_op_ok(&self) -> bool
Return true if the argument has no signal flags, and false
otherwise.
Sourcepub const fn op_signals(&self) -> Signals
pub const fn op_signals(&self) -> Signals
Return the signaling block of given decimal.
Sourcepub const fn classify(&self) -> FpCategory
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);Sourcepub const fn is_normal(&self) -> bool
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());Sourcepub const fn is_subnormal(&self) -> bool
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());Sourcepub const fn is_finite(&self) -> bool
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());Sourcepub const fn is_infinite(&self) -> bool
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());Sourcepub const fn is_sign_positive(&self) -> bool
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());Sourcepub const fn is_sign_negative(&self) -> bool
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());Sourcepub const fn is_one(&self) -> bool
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());Sourcepub const fn is_positive(&self) -> bool
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());Sourcepub const fn is_negative(&self) -> bool
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());Sourcepub const fn with_ctx(self, ctx: Context) -> Self
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.,
INEXACTand 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
- the current value already has some signaling flags set (e.g.,
INEXACT) and the new Context enables traps for those signals; - or possible extra precision rounding operation performs with some Exceptional condition and the new Context enables traps for those Exceptional condition.
§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:
- More about
Decimal contextdecimals. - More about
Exceptional conditions. - Context
- RoundingMode
Sourcepub const fn with_rounding_mode(self, rm: RoundingMode) -> Self
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:
- More about
rounddecimals. - RoundingMode
Sourcepub const fn neg(self) -> Self
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));Sourcepub const fn abs(self) -> Self
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));Sourcepub const fn unsigned_abs(self) -> UnsignedDecimal<N>
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));Sourcepub const fn quantum(exp: i32, ctx: Context) -> Self
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));Sourcepub const fn signum(&self) -> Self
pub const fn signum(&self) -> Self
Returns a number that represents the sign of self.
1.0if the number is positive,+0.0orINFINITY-1.0if the number is negative,-0.0orNEG_INFINITYNANif the number isNAN
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());Sourcepub const fn reduce(self) -> Self
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);Sourcepub const fn eq(&self, other: &Self) -> bool
pub const fn eq(&self, other: &Self) -> bool
Tests for self and other values to be equal, and is used by ==
operator.
Sourcepub const fn ne(&self, other: &Self) -> bool
pub const fn ne(&self, other: &Self) -> bool
Tests for self and other values to be equal, and is used by ==
operator.
Sourcepub const fn max(self, other: Self) -> Self
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));Sourcepub const fn min(self, other: Self) -> Self
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));Sourcepub const fn clamp(self, min: Self, max: Self) -> Self
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));Sourcepub const fn abs_sub(self, other: Self) -> Self
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));Sourcepub const fn lt(&self, other: &Self) -> bool
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);Sourcepub const fn le(&self, other: &Self) -> bool
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);Sourcepub const fn gt(&self, other: &Self) -> bool
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);Sourcepub const fn ge(&self, other: &Self) -> bool
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);Sourcepub const fn cmp(&self, other: &Self) -> Ordering
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);Sourcepub const fn add(self, rhs: Self) -> Self
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.
Sourcepub const fn sub(self, rhs: Self) -> Self
pub const fn sub(self, rhs: Self) -> Self
Calculates self – rhs.
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.
Sourcepub const fn mul(self, rhs: Self) -> Self
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.
Sourcepub const fn div(self, rhs: Self) -> Self
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.
Sourcepub const fn rem(self, rhs: Self) -> Self
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));Sourcepub const fn pow(self, n: Self) -> Self
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.
Sourcepub const fn powi(self, n: i32) -> Self
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.
Sourcepub const fn sqrt(self) -> Self
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.
Sourcepub const fn cbrt(self) -> Self
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.
Sourcepub const fn nth_root(self, n: u32) -> Self
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.
Sourcepub const fn exp(self) -> Self
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.
Sourcepub const fn exp_m1(self) -> Self
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.
Sourcepub const fn exp2(self) -> Self
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.
Sourcepub const fn ln(self) -> Self
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:
- More about the logarithm function.
Sourcepub const fn ln_1p(self) -> Self
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:
- More about the logarithm function.
Sourcepub const fn log(self, base: Self) -> Self
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:
- More about the logarithm function.
Sourcepub const fn log2(self) -> Self
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:
- More about the logarithm function.
Sourcepub const fn log10(self) -> Self
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:
- More about the logarithm function.
Sourcepub const fn hypot(self, other: Self) -> Self
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());Sourcepub const fn mul_add(self, a: Self, b: Self) -> Self
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.
Sourcepub const fn round(self, digits: i16) -> Self
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:
- More about
rounddecimals. - RoundingMode.
Sourcepub const fn trunc(self) -> Self
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:
- More about
truncatedecimals. - Self::trunc_with_scale
- Self::rescale
- Self::quantize
Sourcepub const fn trunc_with_scale(self, scale: i16) -> Self
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:
- More about
truncatedecimals. - Self::trunc
- Self::rescale
- Self::quantize
Sourcepub const fn floor(self) -> Self
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));Sourcepub const fn ceil(self) -> Self
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));Sourcepub const fn rescale(self, new_scale: i16) -> Self
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:
- More about
rescaledecimals. - Self::quantize.
Sourcepub const fn quantize(self, other: Self) -> Self
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:
- More about
quantizedecimals. - Self::rescale.
Sourcepub const fn is_ok(&self) -> bool
pub const fn is_ok(&self) -> bool
Returns:
trueif no Exceptional condition Signals flag has been trapped by Context trap-enabler, andfalseotherwise.
Sourcepub const fn ok(self) -> Option<Self>
pub const fn ok(self) -> Option<Self>
Returns:
Some(Self)if no Exceptional condition Signals flag has been trapped by Context trap-enabler, andNoneotherwise.
Sourcepub const fn recip(self) -> Self
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));Sourcepub const fn to_degrees(self) -> Self
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));Sourcepub const fn to_radians(self) -> Self
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);Sourcepub fn to_scientific_notation(&self) -> String
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");Sourcepub fn to_engineering_notation(&self) -> String
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");Sourcepub const fn transmute<const M: usize>(self) -> Decimal<M>
👎Deprecated since 0.5.0
pub const fn transmute<const M: usize>(self) -> Decimal<M>
Deprecated, use resize instead.
Sourcepub const fn resize<const M: usize>(self) -> Decimal<M>
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 currentContextand corresponding status flags are set.
Behavior details:
- Rounding: extra precision is rounded using the active
RoundingModefrom the current context. - Signals: status flags such as
Inexact,Rounded,Clamped,Overflow, orUnderflowmay 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::Castfor guaranteed-lossless widening (value-preserving by definition). -
Use
crate::TryCastfor 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:
Sourcepub const fn is_even(&self) -> bool
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);Sourcepub const fn is_odd(&self) -> bool
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);Sourcepub const fn is_integral(&self) -> bool
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);Sourcepub const fn sin(self) -> Self
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.
Sourcepub const fn cos(self) -> Self
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.
Sourcepub const fn tan(self) -> Self
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.
Sourcepub const fn asin(self) -> Self
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.
Sourcepub const fn acos(self) -> Self
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.
Sourcepub const fn atan(self) -> Self
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.
Sourcepub const fn atan2(self, other: Self) -> Self
pub const fn atan2(self, other: Self) -> Self
Computes the four quadrant arctangent
of self (y) and other (x).
x = 0,y = 0:0x >= 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.
Sourcepub const fn sin_cos(self) -> (Self, Self)
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.
Sourcepub const fn sinh(self) -> Self
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.
Sourcepub const fn cosh(self) -> Self
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.
Sourcepub const fn tanh(self) -> Self
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.
Sourcepub const fn asinh(self) -> Self
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.
Sourcepub const fn acosh(self) -> Self
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.
Sourcepub const fn atanh(self) -> Self
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.
Sourcepub const fn from_unsigned(ud: UnsignedDecimal<N>) -> Self
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));Sourcepub const fn try_to_unsigned(self) -> Result<UnsignedDecimal<N>, DecimalError>
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> AddAssign for Decimal<N>
impl<const N: usize> AddAssign for Decimal<N>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<const N: usize> AddAssign<f32> for Decimal<N>
impl<const N: usize> AddAssign<f32> for Decimal<N>
Source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
+= operation. Read moreSource§impl<const N: usize> AddAssign<f64> for Decimal<N>
impl<const N: usize> AddAssign<f64> for Decimal<N>
Source§fn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
+= operation. Read moreSource§impl<const N: usize> AddAssign<i8> for Decimal<N>
impl<const N: usize> AddAssign<i8> for Decimal<N>
Source§fn add_assign(&mut self, rhs: i8)
fn add_assign(&mut self, rhs: i8)
+= operation. Read moreSource§impl<const N: usize> AddAssign<i16> for Decimal<N>
impl<const N: usize> AddAssign<i16> for Decimal<N>
Source§fn add_assign(&mut self, rhs: i16)
fn add_assign(&mut self, rhs: i16)
+= operation. Read moreSource§impl<const N: usize> AddAssign<i32> for Decimal<N>
impl<const N: usize> AddAssign<i32> for Decimal<N>
Source§fn add_assign(&mut self, rhs: i32)
fn add_assign(&mut self, rhs: i32)
+= operation. Read moreSource§impl<const N: usize> AddAssign<i64> for Decimal<N>
impl<const N: usize> AddAssign<i64> for Decimal<N>
Source§fn add_assign(&mut self, rhs: i64)
fn add_assign(&mut self, rhs: i64)
+= operation. Read moreSource§impl<const N: usize> AddAssign<i128> for Decimal<N>
impl<const N: usize> AddAssign<i128> for Decimal<N>
Source§fn add_assign(&mut self, rhs: i128)
fn add_assign(&mut self, rhs: i128)
+= operation. Read moreSource§impl<const N: usize> AddAssign<isize> for Decimal<N>
impl<const N: usize> AddAssign<isize> for Decimal<N>
Source§fn add_assign(&mut self, rhs: isize)
fn add_assign(&mut self, rhs: isize)
+= operation. Read moreSource§impl<const N: usize> AddAssign<u8> for Decimal<N>
impl<const N: usize> AddAssign<u8> for Decimal<N>
Source§fn add_assign(&mut self, rhs: u8)
fn add_assign(&mut self, rhs: u8)
+= operation. Read moreSource§impl<const N: usize> AddAssign<u16> for Decimal<N>
impl<const N: usize> AddAssign<u16> for Decimal<N>
Source§fn add_assign(&mut self, rhs: u16)
fn add_assign(&mut self, rhs: u16)
+= operation. Read moreSource§impl<const N: usize> AddAssign<u32> for Decimal<N>
impl<const N: usize> AddAssign<u32> for Decimal<N>
Source§fn add_assign(&mut self, rhs: u32)
fn add_assign(&mut self, rhs: u32)
+= operation. Read moreSource§impl<const N: usize> AddAssign<u64> for Decimal<N>
impl<const N: usize> AddAssign<u64> for Decimal<N>
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
+= operation. Read moreSource§impl<const N: usize> AddAssign<u128> for Decimal<N>
impl<const N: usize> AddAssign<u128> for Decimal<N>
Source§fn add_assign(&mut self, rhs: u128)
fn add_assign(&mut self, rhs: u128)
+= operation. Read moreSource§impl<const N: usize> AddAssign<usize> for Decimal<N>
impl<const N: usize> AddAssign<usize> for Decimal<N>
Source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
+= operation. Read moreSource§impl<const N: usize> AsExpression<Nullable<Numeric>> for &Decimal<N>
impl<const N: usize> AsExpression<Nullable<Numeric>> for &Decimal<N>
Source§fn as_expression(self) -> Self::Expression
fn as_expression(self) -> Self::Expression
Source§impl<const N: usize> AsExpression<Nullable<Numeric>> for Decimal<N>
impl<const N: usize> AsExpression<Nullable<Numeric>> for Decimal<N>
Source§fn as_expression(self) -> Self::Expression
fn as_expression(self) -> Self::Expression
Source§impl<const N: usize> AsExpression<Numeric> for &Decimal<N>
impl<const N: usize> AsExpression<Numeric> for &Decimal<N>
Source§type Expression = Bound<Numeric, &Decimal<N>>
type Expression = Bound<Numeric, &Decimal<N>>
Source§fn as_expression(self) -> Self::Expression
fn as_expression(self) -> Self::Expression
Source§impl<const N: usize> AsExpression<Numeric> for Decimal<N>
impl<const N: usize> AsExpression<Numeric> for Decimal<N>
Source§type Expression = Bound<Numeric, Decimal<N>>
type Expression = Bound<Numeric, Decimal<N>>
Source§fn as_expression(self) -> Self::Expression
fn as_expression(self) -> Self::Expression
Source§impl<const N: usize, const M: usize> Cast<Decimal<N>> for Decimal<N>where
Dimension<N, M>: Widen,
impl<const N: usize, const M: usize> Cast<Decimal<N>> for Decimal<N>where
Dimension<N, M>: Widen,
Source§impl<const N: usize, const M: usize> Cast<Decimal<N>> for UnsignedDecimal<N>where
Dimension<N, M>: Widen,
impl<const N: usize, const M: usize> Cast<Decimal<N>> for UnsignedDecimal<N>where
Dimension<N, M>: Widen,
impl<const N: usize> Copy for Decimal<N>
Source§impl<const N: usize> Decode<'_, Postgres> for Decimal<N>
impl<const N: usize> Decode<'_, Postgres> for Decimal<N>
Source§fn decode(value: PgValueRef<'_>) -> Result<Self, BoxDynError>
fn decode(value: PgValueRef<'_>) -> Result<Self, BoxDynError>
impl<const N: usize> DefaultIsZeroes for Decimal<N>
Source§impl<'de, const N: usize> Deserialize<'de> for Decimal<N>
impl<'de, const N: usize> Deserialize<'de> for Decimal<N>
Source§fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<const N: usize> DivAssign for Decimal<N>
impl<const N: usize> DivAssign for Decimal<N>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl<const N: usize> DivAssign<f32> for Decimal<N>
impl<const N: usize> DivAssign<f32> for Decimal<N>
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
/= operation. Read moreSource§impl<const N: usize> DivAssign<f64> for Decimal<N>
impl<const N: usize> DivAssign<f64> for Decimal<N>
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/= operation. Read moreSource§impl<const N: usize> DivAssign<i8> for Decimal<N>
impl<const N: usize> DivAssign<i8> for Decimal<N>
Source§fn div_assign(&mut self, rhs: i8)
fn div_assign(&mut self, rhs: i8)
/= operation. Read moreSource§impl<const N: usize> DivAssign<i16> for Decimal<N>
impl<const N: usize> DivAssign<i16> for Decimal<N>
Source§fn div_assign(&mut self, rhs: i16)
fn div_assign(&mut self, rhs: i16)
/= operation. Read moreSource§impl<const N: usize> DivAssign<i32> for Decimal<N>
impl<const N: usize> DivAssign<i32> for Decimal<N>
Source§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
/= operation. Read moreSource§impl<const N: usize> DivAssign<i64> for Decimal<N>
impl<const N: usize> DivAssign<i64> for Decimal<N>
Source§fn div_assign(&mut self, rhs: i64)
fn div_assign(&mut self, rhs: i64)
/= operation. Read moreSource§impl<const N: usize> DivAssign<i128> for Decimal<N>
impl<const N: usize> DivAssign<i128> for Decimal<N>
Source§fn div_assign(&mut self, rhs: i128)
fn div_assign(&mut self, rhs: i128)
/= operation. Read moreSource§impl<const N: usize> DivAssign<isize> for Decimal<N>
impl<const N: usize> DivAssign<isize> for Decimal<N>
Source§fn div_assign(&mut self, rhs: isize)
fn div_assign(&mut self, rhs: isize)
/= operation. Read moreSource§impl<const N: usize> DivAssign<u8> for Decimal<N>
impl<const N: usize> DivAssign<u8> for Decimal<N>
Source§fn div_assign(&mut self, rhs: u8)
fn div_assign(&mut self, rhs: u8)
/= operation. Read moreSource§impl<const N: usize> DivAssign<u16> for Decimal<N>
impl<const N: usize> DivAssign<u16> for Decimal<N>
Source§fn div_assign(&mut self, rhs: u16)
fn div_assign(&mut self, rhs: u16)
/= operation. Read moreSource§impl<const N: usize> DivAssign<u32> for Decimal<N>
impl<const N: usize> DivAssign<u32> for Decimal<N>
Source§fn div_assign(&mut self, rhs: u32)
fn div_assign(&mut self, rhs: u32)
/= operation. Read moreSource§impl<const N: usize> DivAssign<u64> for Decimal<N>
impl<const N: usize> DivAssign<u64> for Decimal<N>
Source§fn div_assign(&mut self, rhs: u64)
fn div_assign(&mut self, rhs: u64)
/= operation. Read moreSource§impl<const N: usize> DivAssign<u128> for Decimal<N>
impl<const N: usize> DivAssign<u128> for Decimal<N>
Source§fn div_assign(&mut self, rhs: u128)
fn div_assign(&mut self, rhs: u128)
/= operation. Read moreSource§impl<const N: usize> DivAssign<usize> for Decimal<N>
impl<const N: usize> DivAssign<usize> for Decimal<N>
Source§fn div_assign(&mut self, rhs: usize)
fn div_assign(&mut self, rhs: usize)
/= operation. Read moreSource§impl<const N: usize> Encode<'_, Postgres> for Decimal<N>
impl<const N: usize> Encode<'_, Postgres> for Decimal<N>
Source§fn encode_by_ref(
&self,
buf: &mut PgArgumentBuffer,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Send + Sync>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Send + Sync>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
impl<const N: usize> Eq for Decimal<N>
Source§impl<const N: usize> Float for Decimal<N>
impl<const N: usize> Float for Decimal<N>
Source§fn neg_infinity() -> Self
fn neg_infinity() -> Self
Source§fn min_value() -> Self
fn min_value() -> Self
Source§fn min_positive_value() -> Self
fn min_positive_value() -> Self
Source§fn max_value() -> Self
fn max_value() -> Self
Source§fn is_infinite(self) -> bool
fn is_infinite(self) -> bool
true if this value is positive infinity or negative infinity and
false otherwise. Read moreSource§fn classify(self) -> FpCategory
fn classify(self) -> FpCategory
Source§fn ceil(self) -> Self
fn ceil(self) -> Self
Source§fn round(self) -> Self
fn round(self) -> Self
0.0. Read moreSource§fn is_sign_positive(self) -> bool
fn is_sign_positive(self) -> bool
Source§fn is_sign_negative(self) -> bool
fn is_sign_negative(self) -> bool
true if self is negative, including -0.0,
Float::neg_infinity(), and -Float::nan(). Read moreSource§fn mul_add(self, a: Self, b: Self) -> Self
fn mul_add(self, a: Self, b: Self) -> Self
(self * a) + b with only one rounding
error, yielding a more accurate result than an unfused multiply-add. Read moreSource§fn log(self, base: Self) -> Self
fn log(self, base: Self) -> Self
Source§fn to_degrees(self) -> Self
fn to_degrees(self) -> Self
Source§fn to_radians(self) -> Self
fn to_radians(self) -> Self
Source§fn hypot(self, other: Self) -> Self
fn hypot(self, other: Self) -> Self
x and y. Read moreSource§fn asin(self) -> Self
fn asin(self) -> Self
Source§fn acos(self) -> Self
fn acos(self) -> Self
Source§fn atan(self) -> Self
fn atan(self) -> Self
Source§fn exp_m1(self) -> Self
fn exp_m1(self) -> Self
e^(self) - 1 in a way that is accurate even if the
number is close to zero. Read moreSource§fn ln_1p(self) -> Self
fn ln_1p(self) -> Self
ln(1+n) (natural logarithm) more accurately than if
the operations were performed separately. Read moreSource§impl<const N: usize> FloatConst for Decimal<N>
impl<const N: usize> FloatConst for Decimal<N>
Source§fn FRAC_1_SQRT_2() -> Self
fn FRAC_1_SQRT_2() -> Self
1.0 / sqrt(2.0).Source§fn FRAC_2_SQRT_PI() -> Self
fn FRAC_2_SQRT_PI() -> Self
2.0 / sqrt(π).Source§impl<const N: usize> FloatCore for Decimal<N>
impl<const N: usize> FloatCore for Decimal<N>
Source§fn neg_infinity() -> Self
fn neg_infinity() -> Self
Source§fn min_value() -> Self
fn min_value() -> Self
Source§fn min_positive_value() -> Self
fn min_positive_value() -> Self
Source§fn max_value() -> Self
fn max_value() -> Self
Source§fn is_infinite(self) -> bool
fn is_infinite(self) -> bool
true if the number is infinite. Read moreSource§fn is_normal(self) -> bool
fn is_normal(self) -> bool
true if the number is neither zero, infinite, subnormal or NaN. Read moreSource§fn classify(self) -> FpCategory
fn classify(self) -> FpCategory
Source§fn ceil(self) -> Self
fn ceil(self) -> Self
Source§fn round(self) -> Self
fn round(self) -> Self
0.0. Read moreSource§fn abs(self) -> Self
fn abs(self) -> Self
self. Returns FloatCore::nan() if the
number is FloatCore::nan(). Read moreSource§fn is_sign_positive(self) -> bool
fn is_sign_positive(self) -> bool
true if self is positive, including +0.0 and
FloatCore::infinity(), and FloatCore::nan(). Read moreSource§fn is_sign_negative(self) -> bool
fn is_sign_negative(self) -> bool
true if self is negative, including -0.0 and
FloatCore::neg_infinity(), and -FloatCore::nan(). Read moreSource§fn clamp(self, min: Self, max: Self) -> Self
fn clamp(self, min: Self, max: Self) -> Self
Source§fn recip(self) -> Self
fn recip(self) -> Self
Source§fn to_degrees(self) -> Self
fn to_degrees(self) -> Self
Source§fn to_radians(self) -> Self
fn to_radians(self) -> Self
Source§impl<const N: usize> From<UnsignedDecimal<N>> for Decimal<N>
impl<const N: usize> From<UnsignedDecimal<N>> for Decimal<N>
Source§fn from(ud: UnsignedDecimal<N>) -> Self
fn from(ud: UnsignedDecimal<N>) -> Self
Source§impl<const N: usize> FromPrimitive for Decimal<N>
impl<const N: usize> FromPrimitive for Decimal<N>
Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u16(n: u16) -> Option<Self>
fn from_u16(n: u16) -> Option<Self>
u16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u32(n: u32) -> Option<Self>
fn from_u32(n: u32) -> Option<Self>
u32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§impl<'a, const N: usize> FromSql<'a> for Decimal<N>
impl<'a, const N: usize> FromSql<'a> for Decimal<N>
Source§fn from_sql(
_: &Type,
raw: &'a [u8],
) -> Result<Self, Box<dyn Error + Sync + Send>>
fn from_sql( _: &Type, raw: &'a [u8], ) -> Result<Self, Box<dyn Error + Sync + Send>>
Type in its binary format. Read moreSource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type.Source§impl<const N: usize> MulAssign for Decimal<N>
impl<const N: usize> MulAssign for Decimal<N>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl<const N: usize> MulAssign<f32> for Decimal<N>
impl<const N: usize> MulAssign<f32> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
*= operation. Read moreSource§impl<const N: usize> MulAssign<f64> for Decimal<N>
impl<const N: usize> MulAssign<f64> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*= operation. Read moreSource§impl<const N: usize> MulAssign<i8> for Decimal<N>
impl<const N: usize> MulAssign<i8> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: i8)
fn mul_assign(&mut self, rhs: i8)
*= operation. Read moreSource§impl<const N: usize> MulAssign<i16> for Decimal<N>
impl<const N: usize> MulAssign<i16> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: i16)
fn mul_assign(&mut self, rhs: i16)
*= operation. Read moreSource§impl<const N: usize> MulAssign<i32> for Decimal<N>
impl<const N: usize> MulAssign<i32> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*= operation. Read moreSource§impl<const N: usize> MulAssign<i64> for Decimal<N>
impl<const N: usize> MulAssign<i64> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: i64)
fn mul_assign(&mut self, rhs: i64)
*= operation. Read moreSource§impl<const N: usize> MulAssign<i128> for Decimal<N>
impl<const N: usize> MulAssign<i128> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: i128)
fn mul_assign(&mut self, rhs: i128)
*= operation. Read moreSource§impl<const N: usize> MulAssign<isize> for Decimal<N>
impl<const N: usize> MulAssign<isize> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: isize)
fn mul_assign(&mut self, rhs: isize)
*= operation. Read moreSource§impl<const N: usize> MulAssign<u8> for Decimal<N>
impl<const N: usize> MulAssign<u8> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: u8)
fn mul_assign(&mut self, rhs: u8)
*= operation. Read moreSource§impl<const N: usize> MulAssign<u16> for Decimal<N>
impl<const N: usize> MulAssign<u16> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: u16)
fn mul_assign(&mut self, rhs: u16)
*= operation. Read moreSource§impl<const N: usize> MulAssign<u32> for Decimal<N>
impl<const N: usize> MulAssign<u32> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
*= operation. Read moreSource§impl<const N: usize> MulAssign<u64> for Decimal<N>
impl<const N: usize> MulAssign<u64> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: u64)
fn mul_assign(&mut self, rhs: u64)
*= operation. Read moreSource§impl<const N: usize> MulAssign<u128> for Decimal<N>
impl<const N: usize> MulAssign<u128> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: u128)
fn mul_assign(&mut self, rhs: u128)
*= operation. Read moreSource§impl<const N: usize> MulAssign<usize> for Decimal<N>
impl<const N: usize> MulAssign<usize> for Decimal<N>
Source§fn mul_assign(&mut self, rhs: usize)
fn mul_assign(&mut self, rhs: usize)
*= operation. Read moreSource§impl<const N: usize> Num for Decimal<N>
impl<const N: usize> Num for Decimal<N>
type FromStrRadixErr = ParseError
Source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36). Read moreSource§impl<const N: usize> Ord for Decimal<N>
impl<const N: usize> Ord for Decimal<N>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<const N: usize> PartialOrd for Decimal<N>
impl<const N: usize> PartialOrd for Decimal<N>
Source§impl<const N: usize> PgHasArrayType for Decimal<N>
impl<const N: usize> PgHasArrayType for Decimal<N>
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl<const N: usize> RemAssign for Decimal<N>
impl<const N: usize> RemAssign for Decimal<N>
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read moreSource§impl<const N: usize> RemAssign<f32> for Decimal<N>
impl<const N: usize> RemAssign<f32> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: f32)
fn rem_assign(&mut self, rhs: f32)
%= operation. Read moreSource§impl<const N: usize> RemAssign<f64> for Decimal<N>
impl<const N: usize> RemAssign<f64> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: f64)
fn rem_assign(&mut self, rhs: f64)
%= operation. Read moreSource§impl<const N: usize> RemAssign<i8> for Decimal<N>
impl<const N: usize> RemAssign<i8> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: i8)
fn rem_assign(&mut self, rhs: i8)
%= operation. Read moreSource§impl<const N: usize> RemAssign<i16> for Decimal<N>
impl<const N: usize> RemAssign<i16> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: i16)
fn rem_assign(&mut self, rhs: i16)
%= operation. Read moreSource§impl<const N: usize> RemAssign<i32> for Decimal<N>
impl<const N: usize> RemAssign<i32> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: i32)
fn rem_assign(&mut self, rhs: i32)
%= operation. Read moreSource§impl<const N: usize> RemAssign<i64> for Decimal<N>
impl<const N: usize> RemAssign<i64> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: i64)
fn rem_assign(&mut self, rhs: i64)
%= operation. Read moreSource§impl<const N: usize> RemAssign<i128> for Decimal<N>
impl<const N: usize> RemAssign<i128> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: i128)
fn rem_assign(&mut self, rhs: i128)
%= operation. Read moreSource§impl<const N: usize> RemAssign<isize> for Decimal<N>
impl<const N: usize> RemAssign<isize> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: isize)
fn rem_assign(&mut self, rhs: isize)
%= operation. Read moreSource§impl<const N: usize> RemAssign<u8> for Decimal<N>
impl<const N: usize> RemAssign<u8> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: u8)
fn rem_assign(&mut self, rhs: u8)
%= operation. Read moreSource§impl<const N: usize> RemAssign<u16> for Decimal<N>
impl<const N: usize> RemAssign<u16> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: u16)
fn rem_assign(&mut self, rhs: u16)
%= operation. Read moreSource§impl<const N: usize> RemAssign<u32> for Decimal<N>
impl<const N: usize> RemAssign<u32> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: u32)
fn rem_assign(&mut self, rhs: u32)
%= operation. Read moreSource§impl<const N: usize> RemAssign<u64> for Decimal<N>
impl<const N: usize> RemAssign<u64> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: u64)
fn rem_assign(&mut self, rhs: u64)
%= operation. Read moreSource§impl<const N: usize> RemAssign<u128> for Decimal<N>
impl<const N: usize> RemAssign<u128> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: u128)
fn rem_assign(&mut self, rhs: u128)
%= operation. Read moreSource§impl<const N: usize> RemAssign<usize> for Decimal<N>
impl<const N: usize> RemAssign<usize> for Decimal<N>
Source§fn rem_assign(&mut self, rhs: usize)
fn rem_assign(&mut self, rhs: usize)
%= operation. Read moreSource§impl<const N: usize> Signed for Decimal<N>
impl<const N: usize> Signed for Decimal<N>
Source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Source§impl<const N: usize> SubAssign for Decimal<N>
impl<const N: usize> SubAssign for Decimal<N>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreSource§impl<const N: usize> SubAssign<f32> for Decimal<N>
impl<const N: usize> SubAssign<f32> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
-= operation. Read moreSource§impl<const N: usize> SubAssign<f64> for Decimal<N>
impl<const N: usize> SubAssign<f64> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: f64)
fn sub_assign(&mut self, rhs: f64)
-= operation. Read moreSource§impl<const N: usize> SubAssign<i8> for Decimal<N>
impl<const N: usize> SubAssign<i8> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: i8)
fn sub_assign(&mut self, rhs: i8)
-= operation. Read moreSource§impl<const N: usize> SubAssign<i16> for Decimal<N>
impl<const N: usize> SubAssign<i16> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: i16)
fn sub_assign(&mut self, rhs: i16)
-= operation. Read moreSource§impl<const N: usize> SubAssign<i32> for Decimal<N>
impl<const N: usize> SubAssign<i32> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: i32)
fn sub_assign(&mut self, rhs: i32)
-= operation. Read moreSource§impl<const N: usize> SubAssign<i64> for Decimal<N>
impl<const N: usize> SubAssign<i64> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: i64)
fn sub_assign(&mut self, rhs: i64)
-= operation. Read moreSource§impl<const N: usize> SubAssign<i128> for Decimal<N>
impl<const N: usize> SubAssign<i128> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: i128)
fn sub_assign(&mut self, rhs: i128)
-= operation. Read moreSource§impl<const N: usize> SubAssign<isize> for Decimal<N>
impl<const N: usize> SubAssign<isize> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: isize)
fn sub_assign(&mut self, rhs: isize)
-= operation. Read moreSource§impl<const N: usize> SubAssign<u8> for Decimal<N>
impl<const N: usize> SubAssign<u8> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: u8)
fn sub_assign(&mut self, rhs: u8)
-= operation. Read moreSource§impl<const N: usize> SubAssign<u16> for Decimal<N>
impl<const N: usize> SubAssign<u16> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: u16)
fn sub_assign(&mut self, rhs: u16)
-= operation. Read moreSource§impl<const N: usize> SubAssign<u32> for Decimal<N>
impl<const N: usize> SubAssign<u32> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: u32)
fn sub_assign(&mut self, rhs: u32)
-= operation. Read moreSource§impl<const N: usize> SubAssign<u64> for Decimal<N>
impl<const N: usize> SubAssign<u64> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
-= operation. Read moreSource§impl<const N: usize> SubAssign<u128> for Decimal<N>
impl<const N: usize> SubAssign<u128> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: u128)
fn sub_assign(&mut self, rhs: u128)
-= operation. Read moreSource§impl<const N: usize> SubAssign<usize> for Decimal<N>
impl<const N: usize> SubAssign<usize> for Decimal<N>
Source§fn sub_assign(&mut self, rhs: usize)
fn sub_assign(&mut self, rhs: usize)
-= operation. Read moreSource§impl<const N: usize> ToPrimitive for Decimal<N>
impl<const N: usize> ToPrimitive for Decimal<N>
Source§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self to an isize. If the value cannot be
represented by an isize, then None is returned.Source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self to an i8. If the value cannot be
represented by an i8, then None is returned.Source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self to an i16. If the value cannot be
represented by an i16, then None is returned.Source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self to an i32. If the value cannot be
represented by an i32, then None is returned.Source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self to an i64. If the value cannot be
represented by an i64, then None is returned.Source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self to an i128. If the value cannot be
represented by an i128 (i64 under the default implementation), then
None is returned. Read moreSource§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self to a usize. If the value cannot be
represented by a usize, then None is returned.Source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self to a u8. If the value cannot be
represented by a u8, then None is returned.Source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self to a u16. If the value cannot be
represented by a u16, then None is returned.Source§fn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self to a u32. If the value cannot be
represented by a u32, then None is returned.Source§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self to a u64. If the value cannot be
represented by a u64, then None is returned.Source§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
self to a u128. If the value cannot be
represented by a u128 (u64 under the default implementation), then
None is returned. Read moreSource§impl<const N: usize> ToSql for Decimal<N>
impl<const N: usize> ToSql for Decimal<N>
Source§fn to_sql(
&self,
_: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn to_sql(
&self,
_: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into the binary format of the specified
Postgres Type, appending it to out. Read moreSource§fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> bool
Type.Source§fn to_sql_checked(
&self,
ty: &Type,
out: &mut BytesMut,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut, ) -> Result<IsNull, Box<dyn Error + Sync + Send>>
Source§fn encode_format(&self, _ty: &Type) -> Format
fn encode_format(&self, _ty: &Type) -> Format
Source§impl<const N: usize, const M: usize> TryCast<Decimal<N>> for Decimal<N>where
Dimension<N, M>: Narrow,
impl<const N: usize, const M: usize> TryCast<Decimal<N>> for Decimal<N>where
Dimension<N, M>: Narrow,
Source§impl<const N: usize, const M: usize> TryCast<Decimal<N>> for UnsignedDecimal<N>where
Dimension<N, M>: Narrow,
impl<const N: usize, const M: usize> TryCast<Decimal<N>> for UnsignedDecimal<N>where
Dimension<N, M>: Narrow,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BorrowToSql for Twhere
T: ToSql,
impl<T> BorrowToSql for Twhere
T: ToSql,
Source§fn borrow_to_sql(&self) -> &dyn ToSql
fn borrow_to_sql(&self) -> &dyn ToSql
self as a ToSql trait object.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<I> FromRadix10 for I
impl<I> FromRadix10 for I
Source§impl<I> FromRadix16 for I
impl<I> FromRadix16 for I
Source§impl<I> FromRadix10Signed for I
impl<I> FromRadix10Signed for I
impl<T> FromSqlOwned for Twhere
T: for<'a> FromSql<'a>,
Source§impl<T, ST, DB> FromSqlRow<ST, DB> for Twhere
T: Queryable<ST, DB>,
ST: SqlTypeOrSelectable,
DB: Backend,
<T as Queryable<ST, DB>>::Row: FromStaticSqlRow<ST, DB>,
impl<T, ST, DB> FromSqlRow<ST, DB> for Twhere
T: Queryable<ST, DB>,
ST: SqlTypeOrSelectable,
DB: Backend,
<T as Queryable<ST, DB>>::Row: FromStaticSqlRow<ST, DB>,
Source§impl<T, ST, DB> FromStaticSqlRow<ST, DB> for T
impl<T, ST, DB> FromStaticSqlRow<ST, DB> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreimpl<T> NumAssign for Twhere
T: Num + NumAssignOps,
impl<T, Rhs> NumAssignOps<Rhs> for T
impl<T, Rhs, Output> NumOps<Rhs, Output> for T
Source§impl<T> PartialSchema for Twhere
T: ComposeSchema + ?Sized,
impl<T> PartialSchema for Twhere
T: ComposeSchema + ?Sized,
Source§impl<T> Real for Twhere
T: Float,
impl<T> Real for Twhere
T: Float,
Source§fn min_positive_value() -> T
fn min_positive_value() -> T
Source§fn round(self) -> T
fn round(self) -> T
0.0. Read moreSource§fn is_sign_positive(self) -> bool
fn is_sign_positive(self) -> bool
true if self is positive, including +0.0,
Float::infinity(), and with newer versions of Rust f64::NAN. Read moreSource§fn is_sign_negative(self) -> bool
fn is_sign_negative(self) -> bool
true if self is negative, including -0.0,
Float::neg_infinity(), and with newer versions of Rust -f64::NAN. Read moreSource§fn mul_add(self, a: T, b: T) -> T
fn mul_add(self, a: T, b: T) -> T
(self * a) + b with only one rounding
error, yielding a more accurate result than an unfused multiply-add. Read moreSource§fn log(self, base: T) -> T
fn log(self, base: T) -> T
Source§fn to_degrees(self) -> T
fn to_degrees(self) -> T
Source§fn to_radians(self) -> T
fn to_radians(self) -> T
Source§fn hypot(self, other: T) -> T
fn hypot(self, other: T) -> T
x and y. Read moreSource§fn asin(self) -> T
fn asin(self) -> T
Source§fn acos(self) -> T
fn acos(self) -> T
Source§fn atan(self) -> T
fn atan(self) -> T
Source§fn exp_m1(self) -> T
fn exp_m1(self) -> T
e^(self) - 1 in a way that is accurate even if the
number is close to zero. Read more