Operator | Meaning | Example | Result | Reason |
% | Modulus | x = x % 5 | x = 1 | 11/5=2 with 1 rem. |
++ | increment | x = x++ | x = 11 | ++ after a var is applied after asignment |
++ | increment | x = ++x | x = 12 | ++ before a var is applied before assignment |
-- | decrement | x = x-- | x = 11 | same as x = x++ |
-- | decrement | x = --x | x = 10 | same as x = --x |
- | negation | x = -x | x = -11 | turns pos. to neg. and vice versa |
+ | addition | x = x + x | x = 22 | 11 + 11 = 22 |
Operator | Syntax |
comma | , |
assignment | =, +=, -=, *=, /=, %= |
conditional | ?; |
logical or | || |
logical and | && |
equaily | ==, != (not equal) |
relational | <, <=, >, >= |
mathematical | +, -, *, /, % |
unary | !, -, ++, -- |
call | () |
Assignment | Meaning |
x = y | the value of y is assigned to x |
x += y | x = x + y |
x -= y | x = x - y |
x *= y | x = x * y |
x /= y | x = x/y |
x %= y | x = x % y |
Operator | Example | Meaning |
== | x == y | x equal to y |
!= | x != y | x is not equal to y |
< | x < y | x less than y |
> | x > y | x greater than y |
<= | x <= y | x less than or equal to y |
>= | x >= y | x greater or equal to y |