Abs v0.1.0

Source
Returns the absolute value.

Package: Math

Signature

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

Parameters

NameTypeDescription
xfloat64 / float32The value to measure.

Returns

The magnitude of x, in the same precision as the argument. The sign bit is cleared directly, so Abs(-0.0) is 0.0 and Abs(NaN) is a NaN with the same payload but a cleared sign.

Example

import Math::Abs;

func Main() -> int {
    let a = Abs(-3.5); // 3.5
    let b = Abs(-0.0); // 0.0
    return 0;
}

See also

  • Math — the package overview
  • Min / Max — pick the smaller or larger of two values