The following mathematical operators can be used in combination with integer variables:
Brackets can be used to group statements together and may be necessary when using more than one argument.
Example
- Code:
+ Addition
- Subtraction
* Multiplication
% Modulo
++ Increment by 1
-- Decrement by 1
+= Increment by
-= Decrement by
Brackets can be used to group statements together and may be necessary when using more than one argument.
Example
- Code:
someNumber = (5 + 3) * 2; // Assign someNumber with value 16
someNumber++; // Increment 16 by 1 (= 17)
someNumber += 2; // Increment 17 by 2 (= 19)
someNumber = someNumber % 2; // Divide by 2 and assign the rest (= 1)