Function sqrt

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

Experimental version of sqrt in core. See f64::sqrt for details.

§Examples

#![feature(core_float_math)]

use core::f64;

let positive = 4.0_f64;
let negative = -4.0_f64;
let negative_zero = -0.0_f64;

assert_eq!(f64::sqrt(positive), 2.0);
assert!(f64::sqrt(negative).is_nan());
assert_eq!(f64::sqrt(negative_zero), negative_zero);

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