Arithmetic Operators
In This Lesson, You Will Learn:
- Names and syntax for the various arithmetic operators used within KnowledgeKube Expression Engine.
- The types of task each operator is best suited for, and how they can be combined.
- How operator precedence works, and how it can be overridden using parentheses.
Arithmetic operators are used to calculate a value using one or more operands. As with most operator types, the operands used in conjunction in arithmetic calculations can be any sort of programming object, so long as that object’s associated type is numeric.
Operator | Symbol | Description |
---|---|---|
Addition | + | Evaluate the sum of two numbers. |
Subtraction | - (Binary) | Subtract one number from another. |
Minus | - (Unary) | Converts a positive number to a negative and vice versa. |
Multiplication | * | Multiply two numbers. |
Division | / | Divide the first number by the second number. |
Integer Division | % | Divide the first number by the second number, and then convert the result to an integer. |
Exponent | ^ | Raise a number to the power of an exponent. |
Parenthesis | ( and ) | Enclose a statement, causing that statement to be evaluated before outside operators are applied to it. Used to override operator precedence. |
When you use an arithmetic operator (+, -, *, and /) in an expression, and the value of one of the controls in the expression is null, the result of the entire expression will be null — this is known as Null Propagation.
<< Previous: Lesson Summary | Next: Addition ( + ) >>