To wrap a number within a number system, you associate an index with a repeating set where the 0th index is always 0. eg, an index set table would be as follows for the range 0 thru 4
INDEX: 0,1,2,3,4,5,6,7,8,9,10,11,12
RESULT:0,1,2,3,4,0,1,2,3,4,0,1,2,3
you can see this is similar to a modulus, until you do negative numbers, for example, a range -3 to 3, the relationship would look like
INDEX | RESULT
-9|-2
-8|-1
-7|0
-6|1
-5|2
-4|3
-3|-3
-2|-2
-1|-1
0|0
1|1
2|2
3|3
4|-3
5|-2
6|-1
and so on, and so fourth.
This can be applied to a set of decimals as well. I want to write a function that can wrap a float for a range, but to optimize it, I don't want to use IF statements or loops. I'd like to have a mathematical solutions, so that processing this is straightforward, and quick, without interrupting the processor train.
How would one implement a system such as so?
any guidance on this would be awesome!