abs()
returns the absolute value of the given number.
Syntax: abs(expression)
Returns: Type of value returned will be the same as expression.
Arguments
Name | Description |
expression | A Numeric Expression. |
Example
RETURN abs(-8)
The absolute value of -8 is returned, i.e, 8.
Example
RETURN abs(8)
The absolute value of 8 is returned, i.e, 8.
Considerations
abs(null)
returnsnull
.- If expression is negative, -(expression) (i.e. the negation of expression) is returned.
Example
RETURN abs(4)
Returns the following Result
abs(4) |
4 |
Example
RETURN abs(-3)
Returns the following Result
abs(-3) |
3 |
Example
RETURN abs(5-7)
Returns the following Result
abs(5-7) |
2 |
Example
MATCH (a),(b)
WHERE a.name = 'Robert' AND b.name = 'Sandy'
RETURN abs(a.age - b.age)
Returns the absolute value of the difference between the ages of the 2 people with the name Robert and Sandy. If the age of Robert is 47 and the age of Sandy id 54, then the above query will yield the following result
abs(a.age - b.age) |
7 |
Example
RETURN abs(0)
abs(0) |
0 |
Example
RETURN abs(null)
abs(null) |
null |