Sqrt v0.1.0

Source
Returns the square root.

Package: Math

Signature

func Sqrt(x: float64) -> float64;
func Sqrt(x: float32) -> float32;

Parameters

NameTypeDescription
xfloat64 / float32A non-negative value.

Returns

The non-negative square root of x, computed directly by the hardware square root instruction and correctly rounded. Sqrt(-0.0) is -0.0; Sqrt(x) for any other negative x is a NaN.

Example

import Math::Sqrt;

func Main() -> int {
    let a = Sqrt(144.0); // 12.0
    let b = Sqrt(-1.0);  // NaN
    return 0;
}

See also

  • Math — the package overview
  • Cbrt — cube root, defined for negative arguments
  • Pow — general exponentiation
  • Hypot — √(x² + y²) without overflow