Abs v0.1.0
Returns the absolute value.
Package: Math
Signature
func Abs(x: float64) -> float64;
func Abs(x: float32) -> float32;
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | The 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;
}