Sin/Cos Lookup Tables

Blitz3D Forums/Blitz3D Programming/Sin/Cos Lookup Tables

one thing we know is that * is faster than ^2
You can't even say that in general (though it may be in blitz). It is equally often said that x*2 is slower than x shl 1. That's not so sure. Why? Because all the optimizations you're planning to do in your program are not new and are the kind of things optimizong compilers can do very easily. Here, a compiler can recognize that "2" is a constant integer expression, and evaluates to 2 (!). Thus it can use a left shift by itself to achieve the same result (I have absolutely no idea if blitz does this, though someone reported it does; it's easy to check, and if it doesn't then you can keep this trick in your bag of useful optimization). This means that with compilers that have even a minimal optimizing phase, you can avoid to manually replace pultiplications by 2 by left shifts yourself (thuse keeping a more understanble and straightforwardcode). In this case, better keep left shifts for operations that conceptually really operate on bits and let the compiler do these optimizations.