Arithmetic Operators
- Unary operators have just one operand (-3, +3.4); we rarely use the unary plus
- Binary operators have two operands (x + y, 5 / 4)
- When dividing integers, the fractional part is discarded (truncated); so 10 / 3 is 3 not 10.3333… or 10 and 1/3
- Modulus is the remainder from integer division; both operands must be of integral type (char, int, or long); so 10 % 3 is 1 (10 / 3 is 3 with remainder 1)
- There is no division by 0 in computers. Doing so will TERMINATE YOUR PROGRAM IMMEDIATELY.
Next Slide