3 ms·
That is an accurate calculation, but it is not exact. Moreover, when you do floating point arithmetic, you are not adding the number "0.3" up three times. You
by reikonomusha 13y ago
That is an accurate calculation, but it is not exact.
Moreover, when you do floating point arithmetic, you are not adding the number "0.3" up three times. You are adding an approximation of "0.3" up three times, since 0.3 does not have an exact representation in binary.
What you're saying is akin to saying
"Well, I call 0.3333 + 0.3333 + 0.3333 = 0.9999 <> 1.0 inaccurate in my book."
This is totally accurate, and easier to see because it's in decimal.
The point of them is not that they are accurate to some degree. Floating point numbers have a direct correspondence to a real number. The "problem" is that the reverse is not true, so rounding has to occur.
- coldtea 13y ago>That is an accurate calculation, but it is not exact. You know that accurate is a synonym of exact, right? 1. accurate [noun] (of information, measurements, statistics, etc.) correct in all details; exact. >Moreover, when you do floating point arithmetic, you are not adding the number "0.3" up three times. You are adding an approximation of "0.3" up three times, since 0.3 does not have an exact representation in binary. As a CS graduate, I've known that for some decades. But that's at the floating point level, which is beside the point (no pun intented). What the user wants to add is 0.3 -- he could even have entered that verbatim as his input. How it's done is irrelevant to him. What we're saying in this thread is that if that's what you want to do, and you're handling money, FP is not a good represenation. >What you're saying is akin to saying "Well, I call 0.3333 + 0.3333 + 0.3333 = 0.9999 <> 1.0 inaccurate in my book." No, what I'm saying is akin to saying: "I call EXPLICITLY WRITING 0.3+0.3+0.3 and internally getting 0.3333 + 0.3333 + 0.3333 inaccurate in my book".