Arithmetic Operations
An expression in HCL
DetectExpression Language can contain the basic arithmetic
operations: addition (+), subtraction (-),
multiplication (*), division (/), and modulo
(%) with the usual semantics. These are binary operations that
expect sub-expressions on each side. An expression in HCL
Detect Expression Language
can also contain the unary minus (-) operation that expects a
sub-expression on the right. Finally, parentheses (()) are used for
adjusting precedence, as usual.
Addition operation corresponds to concatenation for the String type
and is the only available operation on this type. Bool type does
not support arithmetic operations. Division applies integer division on integer
types and floating point division on Double types.
The modulo operation yields the remainder from the division of the first operand by the second. It always yields a result with the same sign as its second operand. The absolute value of the result is strictly smaller than the absolute value of the second operand.
Examples:
- A simple arithmetic expression:
(3+4*5.0)/2 - A simple expression involving a
Stringliteral:"area code\tcountry" - A unary minus expression:
-(3+5.0)