[][src]Function spinoso_math::sqrt

pub fn sqrt(value: f64) -> Result<f64, DomainError>

Returns the non-negative square root of the given value.

Domain: [0, INFINITY)

Codomain:[0, INFINITY)

Examples

use spinoso_math as math;
assert_eq!(math::sqrt(0.0), Ok(0.0));
assert_eq!(math::sqrt(1.0), Ok(1.0));
assert_eq!(math::sqrt(9.0), Ok(3.0));

assert!(math::sqrt(-9.0).is_err());

assert!(matches!(math::sqrt(f64::NAN), Ok(result) if result.is_nan()));

Errors

If the result of computing the square root is NAN, a domain error is returned.