abs (Function)

Signature: abs(value: t0) -> t0

Description: Returns the absolute value with the same numeric type as its input, at any integer or float width. A signed integer minimum performs Arith.overflow; the enclosing policy supplies the result. Float absolute value is total: negative zero becomes positive zero, infinities become positive infinity, and NaN remains NaN.

Parameters

  • value (t0): The int or float whose magnitude to take

Returns: t0

Example

let d = abs(0 - 5)  // int: 5
let f = abs(-2.5)   // float: 2.5
d = abs (0 - 5)  // int: 5
f = abs -2.5   // float: 2.5