pub fn primitive_float_cbrt<T>(x: T) -> Twhere
Float: From<T> + PartialOrd<T>,
for<'a> T: ExactFrom<&'a Float> + RoundingFrom<&'a Float> + PrimitiveFloat,Expand description
Takes the cube root of a primitive float, returning a correctly-rounded result.
Unlike the cbrt methods of f32 and f64 (which are not guaranteed to be correctly rounded),
this function returns the primitive float closest to the real cube root of the input, with ties
rounded to even. It is computed by taking the cube root of the exact value of the input at the
appropriate precision.
$$ f(x) = \sqrt[3]{x}. $$
§Worst-case complexity
Constant time and additional memory.
§Examples
use malachite_base::num::basic::traits::NegativeInfinity;
use malachite_float::float::arithmetic::cbrt::primitive_float_cbrt;
assert!(primitive_float_cbrt::<f64>(f64::NAN).is_nan());
assert_eq!(primitive_float_cbrt::<f64>(f64::INFINITY), f64::INFINITY);
assert_eq!(
primitive_float_cbrt::<f64>(f64::NEGATIVE_INFINITY),
f64::NEGATIVE_INFINITY
);
assert_eq!(primitive_float_cbrt::<f64>(27.0), 3.0);
assert_eq!(primitive_float_cbrt::<f64>(-8.0), -2.0);