I have the following code doing Sin/Cos function using a pre-calculated memory table. in the following example the table has 1024*128 items covering all the Sin/Cos values f
This looks pretty good, except for the mod operation. Can you do without it?
If the values are near zero, you can use
while(Value > PI2) Value -= PI2;
while(Value < 0) Value += PI2;
Or it may be faster to cast the index to an integer (possibly out of range) first, then mod that as as integer. If the table size is going to be a multiple of 2, you can even use bit operations (if the compiler doesn't do this already).