Arithmetic Operators
AMPS supports the arithmetic operators +
, -
, *
, /
, %
, and MOD
in expressions. The result of arithmetic operators where one of the operands is NULL
is undefined and evaluates to NULL
.
AMPS distinguishes between floating point and integral types. When an arithmetic operator uses two different types, AMPS will convert the integral type to a floating point value as described in Numeric Types and Literals.
Examples of filter expressions using arithmetic operators:
AMPS numeric types are signed, and the AMPS arithmetic operators correctly handle negative numbers. The MOD
and %
operators preserve the sign of the first argument to the operator. That is, -5 % 3
produces a result of -2
, while 5 % -3
produces a result of 2
.
When using mathematical operators in conjunction with filters, be careful about the placement of the operator. Some operators are used in the XPath expression as well as for mathematical operation (for example, the '/'
operator in division). Therefore, it is important to separate mathematical operators with white space to prevent interpretation as an XPath expression.
Last updated