I need to variably increment and decrement a value, and have it return to the minimum value when a threshold is exceeded, and similarly, have it return to the MAXIMUM value when the mininum is exceeded.
So say my range is 1 to 16, and the current value is 16, if I increment then it should become 1. Conversely, if the value is 1 and I DECREMENT, then the value should go to 16.
The modulo operator (% ) seems to work for the incrementing case, but not for the decrementing case. Is there a good way to do this?