DB2 Version 9.7 for Linux, UNIX, and Windows

ABS or ABSVAL scalar function

Read syntax diagramSkip visual syntax diagram
>>-+-ABS----+--(--expression--)--------------------------------><
   '-ABSVAL-'                     

The schema is SYSIBM.

The SYSFUN version of the ABS (or ABSVAL) function continues to be available.

Returns the absolute value of the argument. The argument can be any built-in numeric data type.

The result has the same data type and length attribute as the argument. The result can be null; if the argument is null, the result is the null value. If the argument is the maximum negative value for SMALLINT, INTEGER or BIGINT, the result is an overflow error.

Notes

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

   ABS(-51234)
returns an INTEGER with a value of 51234.