Forum Discussion
IF comparison not returning correct value
Geeta700 .... The formulas in O5 and Z40 should be:
=ROUND(O4-O3, 2)
=ROUND(Y40-X40, 2)
Note: Round to 2 decimal places because (if) that is the accuracy that you expect. Do not round to an arbitrary number of decimal places like 5.
We have no idea what the exact values are in O3, O4, X40 and Y40. It is interesting to note that 6+5+7 = 18 -- the values in the table in your posting. But of course, that is not calculated with those numbers by an expression of the form O3-O4.
The problem might not even be the infamous "floating-point error" problem. For all we know, what appears to be 18.00 due to formatting in both cells is really 17.9950 in one cell and 18.0049 in another cell due to unrounded calculations elsewhere.
But in general, if you expect a calculation to be accurate to 2 decimal places (for example), explicitly round to that number of decimal places. Formatting alone affects only the appearance of the result.
(I do not recommend setting the "Precision as displayed" option, for oh-so-many reasons.)