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).

Previous sectionNext section


Absolute value function.




Argument Description
n Any number.


$ZABS returns the absolute value of n.



Any number. Can be specified as a value, a variable, or an expression. The expression is evaluated, and the result converted to a positive value. Multiple plus and minus signs are permitted. Leading and trailing zeros are deleted.

For evaluation of mixed numeric strings and non-numeric strings, refer to Strings As Numbers in Using Caché ObjectScript.


The following example returns the absolute value of the number you supply:

   READ "Input a number: ",num
   SET abs=$ZABS(num)
   WRITE "The absolute value of ",num," is ",abs
Copy code to clipboard

See Also