开发者

/fp:fast vs :fp:precise what kind of errors can I encounter?

I'm wondering what kind of errors I can encounter if I set /fp:fast instead of fp:precise? I work under MSV10

I perform /,*,+,- operations o开发者_如何学Cn double with max digits equal to 8, like 1.4379294 (currency rate).


The same errors you always get with double calculations: you never get more than 15 significant digits after you convert the result to decimal, the rest are just random noise digits. The difference between /fp:fast and /fp:precise is what happens to those noise digits.

The /fp:precise option solves a problem with the x86 FPU, it stores intermediate results in the FPU registers with 80 bits of precision. Which can cause subtly different noise digit values if the intermediate value is kept in a register. With /fp:precise, the code generator is forced to flush those values back to memory, truncating them back to 64 bits. That's slow, but does generate more consistent noise. Which matters if you commit the sin of comparing floating point values for equality without an epsilon.

Too much fud for most accountants, using a math library that counts with 10 fingers instead of 2 is a common solution. Which addresses the noise digit problem by eliminating the ones that are generated when you convert numbers from base 10 to base 2. Code will be slow, much slower than /fp:precise since all calculations are made in software without hardware acceleration. But typically not an issue in accounting applications.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜