Limit numbers to a certain range
If I had a range of numbers that I needed to stay within, say 0-480... then I started adding numbers all the way up to 480... but when I hit this upper limit of 480... the number looped back through 0... then continued adding up.
How?
I've seen a sample of this code before, but I can't find it after much searching... it used a symbol such as % or & to do this trick.
Advance thanks,
CircleTime
How?
I've seen a sample of this code before, but I can't find it after much searching... it used a symbol such as % or & to do this trick.
Advance thanks,
CircleTime
Comments
I'm adding a few numbers, but if the total exceeds 480, I want it to loop to 0 and continue up.
For example, if all the added numbers equal 500, I'd like it to return 20.
Thoughts?
that will make it so when that happens it adds 1, then when the numbers 1 and it adds it goes back to 0. So it toggles between 0 and 1.
So for what you want:
change attirubte to (attirubte+1)%481
that expression will add one, then when it gets to 480 and changes itll reset to 0.
Its called modulus, its very usefull for on/off buttons, toggles ect.
PERFECT!!! Thank you.