How do i reset my variable value?

i made a counter, that goes from 0 to 3 then it goes to a branch, i want to reset my value back to 0 when it reaches 4

Check if the value is >= 4 and if it is set “Current” to 0.

You can set it to Modulo (%) 5 every time it changes. Then it will always have value between 0 and 4.

I like this answer better than mine.

Though he does say “reset my value back to 0 when it reaches 4” so he will need a modulo 4 (Current % 4)

1 Like

It worth the mention that it wouldn’t work with a decreasing counter, since it can give back -4 - -1 also when called in a negative integer. It’s incorrect from a mathematical point of view, but it’s a slightly faster algorithm for the computer.

Oh thank you so much, that worked just perfect !!!