The ABS function is a mathematical function that returns the absolute value of the specified numeric expression. The absolute value is a positive value. ABS changes negative values to positive values and does not affect zero or positive values.
Syntax
ABS (numeric_expression)
Parameters
| Parameter | Description |
|---|---|
| numeric_expression | The expression of the exact numeric data types or the approximate numeric data types: NUMBER, FLOAT, BINARY_FLOAT, and BINARY_DOUBLE. |
Return type
The return type is the same as the data type of numeric_expression.
Examples
This example shows the results of using the ABS function for three different numbers.
Execute the following statement:
SELECT ABS(-1.0), ABS(0.0), ABS(1.0), ABS(1.666) FROM DUAL;
The following query result is returned:
+-----------+----------+----------+------------+
| ABS(-1.0) | ABS(0.0) | ABS(1.0) | ABS(1.666) |
+-----------+----------+----------+------------+
| 1 | 0 | 1 | 1.666 |
+-----------+----------+----------+------------+