Reputation: 45
I understand that i can use modulus to loop through positive numbers e.g 0 to 10 would look something like this:
i++; i %= 10;
But how can i make it so instead of starting back at 0 it starts at -10? Thanks.
Upvotes: 0
Views: 78
Reputation: 257
Could this be the solution?
i = i%20 - 10;
Upvotes: 1
Reputation: 537
Don't use modulus.
i++; if (i >= 10) i = -10;