3 ms·
I already knew about the lack of associativity of IEEE floats, but TIL that `pow(x,n)` is more precise than chained multiplications. Good to know.
by pygy_ 13y ago
I already knew about the lack of associativity of IEEE floats, but TIL that `pow(x,n)` is more precise than chained multiplications.
Good to know.
- rbonvall 13y agoTechnically it is not a matter of precision but of accuracy.
- pygy_ 13y agoInteresting, thanks for the correction. I'm neither a native English speaker nor an engineer, and I didn't know about the distinction. https://en.wikipedia.org/wiki/Accuracy_and_precision https://en.wikipedia.org/wiki/Accuracy_and_precision
- taeric 13y agoAlso a crap ton faster, right?
- Narishma 13y agoYes, if by faster you mean slower.
- taeric 13y agoHa! Yes, for floating point. I meant my post to more communicate that moving it behind a library/method would allow you to make that decision elsewhere easily. I did not even come close to making that point. (I got distracted reading some interesting hacks that approximate this in insane speed.)