Skip to main content

pow

Function pow 

Source
pub fn pow(base: &DBig, exponent: &DBig, precision: usize) -> OxiNumResult<DBig>
Expand description

Compute base^exp for arbitrary float exponents.

Uses the identity base^exp = e^(exp * ln(base)).

§Errors

Returns OxiNumError::Precision if base <= 0.

§Examples

use oxinum_float::pow;
use std::str::FromStr;
let base = dashu_float::DBig::from_str("2.0").unwrap();
let exp = dashu_float::DBig::from_str("10.0").unwrap();
let result = pow(&base, &exp, 20).unwrap();
let s = result.to_string();
assert!(s.starts_with("1024"), "2^10 = {}", s);