How to code circular int?

Hello. Whats the best way to code circular int?
So for example I have
int red_color = 255;
and if someone initialize red_color = 256; it will be changed to 1. Because 255 is max value for rgb. Thanks :).
actually, you probably want to change the value to 0 because legal values are 0 - 255.

You want to use the modulo operator:

red_color = red_color % 256;
or
red_color %= 256;

Thanks!
Topic archived. No new replies allowed.