Skip to main content

sqrt

Function sqrt 

Source
pub fn sqrt(x: &DBig, precision: usize) -> OxiNumResult<DBig>
Expand description

Compute the square root of x with the given precision.

§Errors

Returns OxiNumError::Precision if x < 0.

§Examples

use oxinum_float::sqrt;
use std::str::FromStr;
let x = dashu_float::DBig::from_str("2.0").unwrap();
let result = sqrt(&x, 30).unwrap();
let s = result.to_string();
assert!(s.starts_with("1.4142135"), "sqrt(2) = {}", s);