Hi
Dealing with vectors using floats but using Math.sqrt() and a cast to find magnitude, etc., I started to wonder if wasting the extra digits from the returned double was ‘okay’ and if it could be done any faster. So some reading and testing different methods and I largely realised I won’t beat hardware but then some strange things happened. See here:
https://gist.github.com/danieldean/5d2abab25bc9b8041d1e
When run the method ‘slow()’ which I named so because I though it would be, frequently out performs Java’s native methods with negligible difference in accuracy. Clearly it would stray off as numbers go higher but if it were tuned to the application is this not going to prove faster?
I probably would never bother using anything but Math.sqrt() but I’d like to know what’s going on here… ???