Arithmetic operators
Arithmetic operators perform an arithmetic operation on two numeric operands. The result of an arithmetic operation is again a numeric value.
FQL supports the following arithmetic operators:
+addition-subtraction*multiplication/division%modulus
Unary plus and unary minus are supported as well:
For exponentiation, there is a numeric function POW(). The syntax base ** exp is not supported.
Some example arithmetic operations:
Type conversion
Arithmetic operators accept operands of any type. The conversion rules depend on the operator.
Addition
The + operator performs numeric addition when both operands are numbers. When either operand is a string, it performs string concatenation instead. All other types are converted to their string representation before concatenation.
Subtraction, multiplication, division, and modulus
The -, *, /, and % operators always convert their operands to numbers. The conversion rules are:
NONEis converted to0.falseis converted to0,trueis converted to1.- A valid numeric value remains unchanged.
- String values are converted to a number if they contain a valid numeric representation. Strings with non-numeric contents are converted to
0. - An empty array is converted to
0. A non-empty array is converted by summing the numeric values of all its elements. - Objects, binary, and custom types are converted to
0.