ABS or ABSVAL
The ABS function returns the absolute value of a number.
- expression
- An expression that returns a value of any built-in numeric, character-string, or graphic-string data type. A string argument is cast to double-precision floating point before evaluating the function. For more information about converting strings to double-precision floating point, see DOUBLE_PRECISION or DOUBLE.
The data type of the result is the same as
the data type of the argument values except that the result is:
- A double-precision floating point if the argument values are single-precision floating point
- A large integer if the argument values are small integers
- A decimal with precision mp and scale s if the argument values are decimal or nonzero scale binary numbers with precision p and scale s.
Note
Results involving
DECFLOAT special values: For decimal floating-point values, the
special values are treated as follows:
- ABS(NaN) and ABS(-NaN) return NaN.
- ABS(Infinity) and ABS(-Infinity) return Infinity.
- ABS(sNaN) and ABS(-sNaN) return sNaN.
Example
- Assume the host variable PROFIT is a large integer with a value
of -50000.
Returns the value 50000.SELECT ABS(:PROFIT) FROM SYSIBM.SYSDUMMY1