I'm trying to use bit flags and cycle through them in the fashion: 1, 2, 4, 1, 2, 4, etc., depending on the available modes (i.e. if modes = MODE1 | MODE3, the cycle is 1, 4, 1, 4). My concern is, what is the best way to determine if it has reached the final mode? What is the best way to loop it back to the smallest mode?
This could easily be done using a list, but I want to try it with a number instead.