# Trait rust_decimal::MathematicalOps

``````pub trait MathematicalOps {
Show 27 methods    // Required methods
fn exp(&self) -> Decimal;
fn checked_exp(&self) -> Option<Decimal>;
fn exp_with_tolerance(&self, tolerance: Decimal) -> Decimal;
fn checked_exp_with_tolerance(&self, tolerance: Decimal) -> Option<Decimal>;
fn powi(&self, exp: i64) -> Decimal;
fn checked_powi(&self, exp: i64) -> Option<Decimal>;
fn powu(&self, exp: u64) -> Decimal;
fn checked_powu(&self, exp: u64) -> Option<Decimal>;
fn powf(&self, exp: f64) -> Decimal;
fn checked_powf(&self, exp: f64) -> Option<Decimal>;
fn powd(&self, exp: Decimal) -> Decimal;
fn checked_powd(&self, exp: Decimal) -> Option<Decimal>;
fn sqrt(&self) -> Option<Decimal>;
fn ln(&self) -> Decimal;
fn checked_ln(&self) -> Option<Decimal>;
fn log10(&self) -> Decimal;
fn checked_log10(&self) -> Option<Decimal>;
fn erf(&self) -> Decimal;
fn norm_cdf(&self) -> Decimal;
fn norm_pdf(&self) -> Decimal;
fn checked_norm_pdf(&self) -> Option<Decimal>;
fn sin(&self) -> Decimal;
fn checked_sin(&self) -> Option<Decimal>;
fn cos(&self) -> Decimal;
fn checked_cos(&self) -> Option<Decimal>;
fn tan(&self) -> Decimal;
fn checked_tan(&self) -> Option<Decimal>;
}``````
Available on crate feature `maths` only.
Expand description

Trait exposing various mathematical operations that can be applied using a Decimal. This is only present when the `maths` feature has been enabled.

## Required Methods§

source

#### fn exp(&self) -> Decimal

The estimated exponential function, ex. Stops calculating when it is within tolerance of roughly `0.0000002`.

source

#### fn checked_exp(&self) -> Option<Decimal>

The estimated exponential function, ex. Stops calculating when it is within tolerance of roughly `0.0000002`. Returns `None` on overflow.

source

#### fn exp_with_tolerance(&self, tolerance: Decimal) -> Decimal

The estimated exponential function, ex using the `tolerance` provided as a hint as to when to stop calculating. A larger tolerance will cause the number to stop calculating sooner at the potential cost of a slightly less accurate result.

source

#### fn checked_exp_with_tolerance(&self, tolerance: Decimal) -> Option<Decimal>

The estimated exponential function, ex using the `tolerance` provided as a hint as to when to stop calculating. A larger tolerance will cause the number to stop calculating sooner at the potential cost of a slightly less accurate result. Returns `None` on overflow.

source

#### fn powi(&self, exp: i64) -> Decimal

Raise self to the given integer exponent: xy

source

#### fn checked_powi(&self, exp: i64) -> Option<Decimal>

Raise self to the given integer exponent xy returning `None` on overflow.

source

#### fn powu(&self, exp: u64) -> Decimal

Raise self to the given unsigned integer exponent: xy

source

#### fn checked_powu(&self, exp: u64) -> Option<Decimal>

Raise self to the given unsigned integer exponent xy returning `None` on overflow.

source

#### fn powf(&self, exp: f64) -> Decimal

Raise self to the given floating point exponent: xy

source

#### fn checked_powf(&self, exp: f64) -> Option<Decimal>

Raise self to the given floating point exponent xy returning `None` on overflow.

source

#### fn powd(&self, exp: Decimal) -> Decimal

Raise self to the given Decimal exponent: xy. If `exp` is not whole then the approximation ey*ln(x) is used.

source

#### fn checked_powd(&self, exp: Decimal) -> Option<Decimal>

Raise self to the given Decimal exponent xy returning `None` on overflow. If `exp` is not whole then the approximation ey*ln(x) is used.

source

#### fn sqrt(&self) -> Option<Decimal>

The square root of a Decimal. Uses a standard Babylonian method.

source

#### fn ln(&self) -> Decimal

Calculates the natural logarithm for a Decimal calculated using Taylor’s series.

source

#### fn checked_ln(&self) -> Option<Decimal>

Calculates the checked natural logarithm for a Decimal calculated using Taylor’s series. Returns `None` for negative numbers or zero.

source

#### fn log10(&self) -> Decimal

Calculates the base 10 logarithm of a specified Decimal number.

source

#### fn checked_log10(&self) -> Option<Decimal>

Calculates the checked base 10 logarithm of a specified Decimal number. Returns `None` for negative numbers or zero.

source

#### fn erf(&self) -> Decimal

Abramowitz Approximation of Error Function from wikipedia

source

#### fn norm_cdf(&self) -> Decimal

The Cumulative distribution function for a Normal distribution

source

#### fn norm_pdf(&self) -> Decimal

The Probability density function for a Normal distribution.

source

#### fn checked_norm_pdf(&self) -> Option<Decimal>

The Probability density function for a Normal distribution returning `None` on overflow.

source

#### fn sin(&self) -> Decimal

Computes the sine of a number (in radians). Panics upon overflow.

source

#### fn checked_sin(&self) -> Option<Decimal>

Computes the checked sine of a number (in radians).

source

#### fn cos(&self) -> Decimal

Computes the cosine of a number (in radians). Panics upon overflow.

source

#### fn checked_cos(&self) -> Option<Decimal>

Computes the checked cosine of a number (in radians).

source

#### fn tan(&self) -> Decimal

Computes the tangent of a number (in radians). Panics upon overflow or upon approaching a limit.

source

#### fn checked_tan(&self) -> Option<Decimal>

Computes the checked tangent of a number (in radians). Returns None on limit.

source§