The abs command returns the absolute value of an integer. This return value is always greater than or equal to zero. If a variable of type float is passed in as an argument, the abs command performs a truncating integer conversion, then returns the absolute value of that integer. If the input data is floating point and you want the output type to be floating point, use the fabs command.
Math
abs number |
Name | Type | Required | Comments |
---|---|---|---|
number | integer | yes | If num is of type float, a truncation is used to convert to int. |
None
integer |
Returns an integer that is greater than or equal to 0
// the following script shows that positive 1 is returned for // both calls to abs int $integer_variable = 1.0; float $float_variable = 1.9; int $abs_of_float_variable = `abs $float_variable`; int $abs_of_integer_variable = `abs $integer_variable`; print("i is " + string($abs_of_integer_variable)); print("f is " + string($abs_of_float_variable)); |