Function bigdecimalmath::root [−][src]
pub fn root(n: isize, x: BigDecimal) -> Result<BigDecimal, BigDecimalMathError>
Expand description
Calculates the n-th root of a BigDecimal rounded to the precision implied by x, x^(1/n).
Arguments
n
- the positive rootx
- the non-negative number we are calculating the n-th root of
Example
use bigdecimal::BigDecimal; use std::str::FromStr; use bigdecimalmath::root; let n = 4; let x = BigDecimal::from_str("14.75").unwrap(); assert_eq!(Ok(BigDecimal::from_str("1.9597").unwrap()), root(n,x));