Arithmetic Operators

modulus gives the remainder after division

Examples using modulus

15 % 2 is 1 15 % 3 is 0 5 % 7 is 5


Relational Operators

== equality Usage: x == y evaluates to false, 0, or true, non0 != inequality Usage: x != y evaluates to false, 0, or true, non0 > greater than < less than >= greater than or equal to <= less than or equal to


Operator precedence and associativity

operator associativity ( ) left to right * / % left to right + - left to right < <= > >= left to right == != left to right = right to left Important. Note that multiplication and division have higher precedence than addition and subtraction. These four operators also associate left to right. The assignment (=) is an operator too; it associates right to left.