abs

Computes the absolute value of an expression.

Syntax


  intExpr abs(intExpr x)
floatExpr abs(floatExpr x)

Parameters

  • x: integer or floating-point expression for which the absolute value is to be computed.

Description

Function abs computes the absolute value of an integer or floating-point expression x. The type of the function is the same as the type of its argument. abs(x) is a more efficient way of writing max(x, -x).

Example


a = intVar(0..9);
abs(a-5) == 3;

The problem above has two solutions: a=2 and a=8.