ABS()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns the absolute (non-negative) value of the given argument.
USAGE
ABS(number)
Argument Name | Description |
---|---|
| The number to evaluate |
DETAILS
ABS()
is a mathematical function that returns the absolute value of its argument:
If the argument is
NULL
the result isNULL
If the argument is >= 0, the result is the argument value.
Otherwise, the result is
-1
multiplied by the argument value.
The data type of the result is the same as the data type of the argument.
EXAMPLES
SELECT ABS(-5), ABS(8);
+---------+--------+
| ABS(-5) | ABS(8) |
+---------+--------+
| 5 | 8 |
+---------+--------+
Out-of-Range
A value is considered "out-of-range" when it is too small or too large to be stored in a data type. The value is rounded to the nearest valid value.
SELECT ABS(-9223372036854775808);
+---------------------------+
| ABS(-9223372036854775808) |
+---------------------------+
| -9223372036854775808 |
+---------------------------+