Operators
The following operators are supported:
-
a + b
The return value is the addition of both operands a and b. - a - b
The return value is the subtraction of operand b from operand a. - a * b
The return value is the multiplication of operand b from operand a. a / b - Note: If b is 0, the expression will raise an exception
- Note: By default, if both operands are integers, and the division has no remainder, the result will be an integer as well.
However, if the division does have a remainder, the result will be promoted to decimal instead. You can turn off this behaviour using the Preferences dialog, option Integer division can promote operands to decimal, which will result in "standard computer behaviour" -
a % b
The return value is the remainder of operand a divided by operand b- Note: If b is 0, the expression will raise an exception
- Note: Modulo is defined for integers only. If one or both of the operands are decimals, they will be converted to integer values before the operation proceeds. This also means that the result of this operation will always be an integer.
-
a ** b or a ^ b
The return value is the a to the power of b.
- Note: If both operands are integers, but the exponent is negative, the result will be promoted to decimal.
- Note: The maximum exponent value is specified in the preferences. By default, this is 1.000.000, which will result in an integer of over 300.000 digits.
-
a!
Return the factorial of a.
- Note: This operation is defined for integers only, so an input decimal will be demoted to integer.
-
| a |
Return the absolute value of a. -
a << b
Return a shifted left by b bits.
- Note: This operation is defined for integers only, so both operands will be demoted to integer.
-
a >> b
Return a shifted right by b bits.
- Note: This operation is defined for integers only, so both operands will be demoted to integer.
-
a == b
Return True if a equals b, or False otherwise
-
a <> b
Return True if a does not equal b, or False otherwise
-
a <= b
Return True if a is less than or equal b, or False otherwise
-
a >= b
Return True if a is greater than or equal b, or False otherwise
-
a < b
Return True if a is less than b, or False otherwise
-
a > b
Return True if a is greater than b, or False otherwise
The return value is the division of operand a by operand b.
Operator Precedence
The following operator precedence levels are supported (ordered from highest binding to lowest):
- ( expression )
- a ! and - a
- a >> b and a << b
- a ** b
- a * b, a / b and a % b
- a + b and a - b
- a == b, a <> b, a <= b, a >= b, a < b, a > b
Basically, what this means is that the usual mathematical rules apply: expressions in brackets have highest precedence, + and - has a lower precedence than * and /