Created attachment 176330 [details] calc sheet sample test I note the following: subtracting two values the result is not always accurate. An example: 3912,24000000000000-3892,96000000000000 = 19,27999999999970 the result should be 19,28 but a comparison =if((x-y)=19,28;"OK";"notOK") gives the result "notOK". (see attached test, noting that the decimal separator is comma (IT))
2 - 1 is 1, but a.y - b.y is not necessarily what you expect - see FAQ [1]. Closing NOTABUG. [1] https://wiki.documentfoundation.org/Faq/Calc/Accuracy
(In reply to Mike Kaganski from comment #1) Yes, such inaccuracies are inevitable in <https://en.wikipedia.org/wiki/Floating-point_arithmetic> and not a LibO Problem. Some days ago That caused a very annoying CALC Filter problem for me, but I did not find the time for deeper investigations.
Ok, it will be inevitable but, often using comparisons between values and obtaining results that are not always reliable but on which reliability is important to continue in other cascade operations, what can be done to overcome the problem?
(In reply to gmarco from comment #3) As mentioned in FAQ (see comment 1): > Users need to account for that, and use rounding and *comparisons with epsilon* as necessary =IF(ABS((x-y)-19)<1E-10;"OK";"notOK") ... or any other value suitable in this case (for different values, value of epsilon may vary).
> > =IF(ABS((x-y)-19)<1E-10;"OK";"notOK") > > ... or any other value suitable in this case (for different values, value of > epsilon may vary). Well, I'll try changing the formulas, I generally use the comparison "= 0" or "> 0" or "<> 0" and I hope that fitting them with "<1E-10" is OK.
Thanks, the formula works and can be simplified like this: x y x-y = z 3912,24000000000000 3892,96000000000000 19,27999999999970 that is x y x-y = z 3912,24 3892,96 19,28 =IF(x-y=ABS(z);"OK";"notOK")