Function cbrt

Source
pub fn cbrt(x: f32) -> f32
🔬This is a nightly-only experimental API. (core_float_math)
Expand description

Experimental version of cbrt in core. See f32::cbrt for details.

§Unspecified precision

The precision of this function is non-deterministic. This means it varies by platform, Rust version, and can even differ within the same execution from one invocation to the next. This function currently corresponds to the cbrtf from libc on Unix and Windows. Note that this might change in the future.

§Examples

#![feature(core_float_math)]

use core::f32;

let x = 8.0f32;

// x^(1/3) - 2 == 0
let abs_difference = (f32::cbrt(x) - 2.0).abs();

assert!(abs_difference <= f32::EPSILON);

This standalone function is for testing only. It will be stabilized as an inherent method.