I'd guess that it's due to how floating point values are stored imprecisely in memory, causing the weird results to come up on rare occasions.
Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
>The code processes millions of transactions, but less than .01 % has this error. Any ideas?
That's a typical floating-point rounding fudge. If it's a serious enough problem, you can try to use a more precise type such as long double, or remove floating-point altogether to maintain exact precision. Though I suspect that an imprecision at the eighth decimal place isn't that much of an issue unless you're trying to do something with vanilla C++ types that shouldn't be done with vanilla C++ types. If that's the case, you really need to get a high precision mathematics library.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401