var const |
Problem description:
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.

If your bits are in order: 1, 2, 4, 8, 16, etc... Then you can simply increase mode by 1 and check if it's not over