Topic group Related topics
Binary numeric operators: + * / % ^ **
Unary numeric operators: ++
n + m
n - m
n * m
n / m
n % m
n ^ m
n ** m
Perform standard arithmetic operations on two operands, or increment or decrement a single operand.
All of these operators take numeric values as operands. The + (plus) and - (minus) symbols can also be used to concatenate strings.
As binary numeric operators, the +, , *, and / symbols perform the standard arithmetic operations addition, subtraction, multiplication and division.
The modulus operator returns the remainder of an integral division operation on its two operands. For example, 50%8 returns 2, which is the remainder after dividing 50 by 8.
You may use either ^ or ** for exponentiation. For example, 2^5 is 32.
The increment/decrement operators ++ and take a variable or property and increase or decrease its value by one. The operator may be used before the variable or property as a prefix operator, or afterward as postfix operator. For example,
n = 5 // Start with 5
? n++ // Get value (5), then increment
? n // Now 6
? ++n // Increment first, then get value (7)
? n // Still 7
If the value is not used immediately, it doesnt matter whether the ++/ operator is prefix or postfix, but the convention is postfix.