abs
mathReturns the absolute value of a number
Syntax
abs(number) Parameters
number (number) The number to get the absolute value of
Returns
number The absolute (non-negative) value
Examples
Input:
-5 | abs Output:
5 Input:
abs(3.14) Output:
3.14 Input:
abs(-42) Output:
42 The abs() function returns the absolute value of a number, converting negative numbers to positive while leaving positive numbers unchanged.
Usage
Use abs() when you need to work with magnitudes regardless of sign, such as calculating distances or differences.