Arithmetic on a Circle
A Programming Pattern |
Prof. David Bernstein |
Computer Science Department |
bernstdh@jmu.edu |
Addition on the Line
Subtraction on the Line
Addition on the Circle
Subtraction on the Circle
current
denotes the current valuechange
denotes the change (either positive
or negative)cardinality
denotes the number of elements
in the set of valuespasses = (current + change) / cardinality;
remainder = (current + change) % cardinality;
29 % 24
or 5:00110 % 24
or 14:00%
:
x % 2
equal 0?