abs
Find the absolute value of the argument
Definition
number abs(number $value)
If $value is a number, returns the absolute value of the argument, equal to $value if $value is greater or equal to zero, and -$value if $value is less or equal to zero.
Parameters
number $value
Number to calculate the absolute value of.
Returns
number
A number greater or equal to zero, the absolute value of $value.
Examples
{
negativeNum: abs(`-1`),
positiveNum: abs(`2`),
stringNum: abs('3.0'),
truth: abs(`true`),
falsity: abs(`false`),
none: abs(`null`),
text: abs(`"text"`), // Error
array: abs(`[]`), // Error
object: abs(`{}`) // Error
}{
"negativeNum": 1,
"positiveNum": 2,
"stringNum": 3.0,
"truth": 1.0,
"falsity": 0.0,
"none": 0.0
}Remarks
Accepts Boolean, null and strings with correct number format arguments as well, in which case the argument is converted to number implicitly before calculating the absolute value. Other argument types raise an Error and return null.
Updated 5 months ago
What’s Next