pub fn primitive_float_unsigned_pow<T>(x: u64, y: T) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Raises a u64 to the power of a primitive float, returning a primitive float.
The result is correctly rounded to the nearest value.
$$ f(x,y) = x^y+\varepsilon. $$
- If $x^y$ is infinite, zero, or
NaN, $\varepsilon$ may be ignored or assumed to be 0. - If $x^y$ is finite and nonzero, then $|\varepsilon| < 2^{\lfloor\log_2 x^y\rfloor-p}$, where
$p$ is the precision of the output (typically 24 if
Tis af32and 53 ifTis af64, but less if the output is subnormal).
Special cases:
- $f(x,0.0)=1.0$ for any $x$
- $f(1,y)=1.0$ for any $y$, even
NaN - $f(x,\text{NaN})=\text{NaN}$ if $x \neq 1$
- $f(x,\infty)=\infty$ if $x>1$, and $0.0$ if $x=0$
- $f(x,-\infty)=0.0$ if $x>1$, and $\infty$ if $x=0$
- $f(0,y)=0.0$ if $y>0$, and $\infty$ if $y<0$
If the result overflows, $\infty$ is returned, and if it underflows, $0.0$ is returned.
§Worst-case complexity
Constant time and additional memory.
§Examples
use malachite_base::num::float::NiceFloat;
use malachite_float::float::arithmetic::pow::primitive_float_unsigned_pow;
assert_eq!(
NiceFloat(primitive_float_unsigned_pow(2, 0.5)),
NiceFloat(1.4142135623730951)
);
assert_eq!(
NiceFloat(primitive_float_unsigned_pow(3, 2.5)),
NiceFloat(15.588457268119896)
);
assert_eq!(
NiceFloat(primitive_float_unsigned_pow(2, -1.0)),
NiceFloat(0.5)
);