The MySQL abs() function is used to return the absolute value or modulus |x| of a real number x is the non-negative value of x without regard to its sign.
|x| = √x2 ⇒ √-32 = 3
where x = -3
abs(number);
SELECT ABS(0) AS `Absolute Value`; -- Integer Value
SELECT ABS(-3) AS `Absolute Value`; -- Negative Value
SELECT ABS(-2.53) AS `Absolute Value`; -- Float Value
abs(number);
mixed number |
It may be either integer or float |
Return |
Returns an number respective to an input (int, long, short, float, decimal) |
abs(number);
-- Absoulte Value - Positive Integer Values
SELECT ABS(6) AS `Absolute Value`;
SELECT ABS(0) AS `Absolute Value`;
-- Absoulte Value - Negative Integer Values
SELECT ABS(-3) AS `Absolute Value`;
SELECT ABS(-0) AS `Absolute Value`;
abs(number);
-- Absoulte Value - Positive Float Values
SELECT ABS(3,14) AS `Absolute Value`;
SELECT ABS(0.00) AS `Absolute Value`;
-- Absoulte Value - Negative Float Values
SELECT ABS(-0.56) AS `Absolute Value`;
SELECT ABS(-0.00) AS `Absolute Value`;