Floating point precision.

Hello,

Just a quick question this time!
I've experienced several times that comparing non-integers to exact values is generally a bad idea (cases where (a - a) > 0, and so on) due to precision issues. In my current application, I need to check whether a certain value has changed, thus something along the line of (a == old.a).

Now, if I can guarantee that a and old.a were calculated in the same way, can I with certainty say that "hasn't changed" scenarios will be caught using simple comparison? Thus, will the inaccuracy be consistent?

If no, what if I only use +, - and *? (No division or more advanced calculations)

If yes to either of the above: MS Visual C++ has a compiler setting "Floating Point model: /fp:fast". Will this change the answer to any of the above questions?

Note that I don't care too much about the precision of the actual results; all I care about is that equal results are identified.
Last edited on
Topic archived. No new replies allowed.