3 ms·
Summing floating point numbers in a simple loop is just as bad. It's not an issue of efficiency, it's an issue of accuracy.
by jfager 17y ago
Summing floating point numbers in a simple loop is just as bad. It's not an issue of efficiency, it's an issue of accuracy.
- sreque 17y agoI guess I've been causing the death of kittens for a while then. I couldn't, however, deduce from your wikipedia link or from a quick google search what the correct way of adding floating point numbers should be, though. Even the MS compiler guys at http://msdn.microsoft.com/en-us/library/aa289157%28VS.71%29.aspx http://msdn.microsoft.com/en-us/library/aa289157%28VS.71%29.... are writing code snippets that sum floating point numbers in a loop. edit: You're write jfager. I didn't read the article I linked to very carefully. The article actually has an example algorithm, the Kahan sum, for reducing the error caused by summing floating point numbers in a loop!
- jfager 17y agoThe whole point of the article you linked to is how to avoid summing floating point numbers in a simple loop.