Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Next section


A numeric function that returns the absolute value of a numeric expression.


{fn ABS(numeric-expression)}


Argument Description
numeric-expression A number whose absolute value is to be returned.


ABS returns the absolute value, which is always zero or a positive number. ABS returns the same data type as numeric-expression. If numeric-expression is not a number (for example, the string 'abc', or the empty string '') ABS returns 0. ABS returns <null> when passed a NULL value.

Note that ABS can be used as an ODBC scalar function (with the curly brace syntax) or as an SQL general function.

This function can also be invoked from ObjectScript using the ABS() method call:

Copy code to clipboard


The following example shows the two forms of ABS:

SELECT ABS(-99) AS AbsGen,{fn ABS(-99)} AS AbsODBC
Copy code to clipboard

both returns 99.

The following examples show how ABS handles some other numbers. Caché SQL converts numeric-expression to canonical form, deleting leading and trailing zeros and evaluating exponents, before invoking ABS.

SELECT ABS(007) AS AbsoluteValue
Copy code to clipboard

returns 7.

SELECT ABS(-0.000) AS AbsoluteValue
Copy code to clipboard

returns 0.

SELECT ABS(-99E4) AS AbsoluteValue
Copy code to clipboard

returns 990000.

SELECT ABS(-99E-4) AS AbsoluteValue
Copy code to clipboard

returns .0099.

See Also