Subtration A1 - B1 gives wrong result in Calc

In one of my Calc spreadsheets, using the comma as the decimal point, I have three cells :

A1 = 8593,65
B1 = 8527,73
C1 = A-B

Much to my surprise, when showing 20 digits after the comma, C shows 65,92000000000010000000. When I show all values with 20 digits after the comma, A1 correctly shows 8593,65000000000000000000 and B1 correctly shows 8527,73000000000000000000.

Anyone any idea where this error comes from ?

Please see this explanation, Numeric precision in Microsoft Excel - Wikipedia

And also Frequently asked questions - Calc: Accuracy problem - The Document Foundation Wiki

1 Like

.
Similarly to the fact that you can not show the precise result for the division 1/3(dec) (= 0.33333333333333333333333…(dec)) in the decimal system, you can not show the result of the division 1/10(dec) in the binary system. You never can show the PRECISE result.
.
“Surprisingly” the result of the decimal fraction 1/10(dec) is an infinite fraction in the binary system = 0.00011001100110011001100…(bin) = 1/16+1/32+1/256+1/512+1/4086+1/8192…
.
In other words: the numeric systems always have some small errors, but not at same numeric values, depended on the base number of the system.
.
It is not an error of the LibreOffice Calc, is is nor an error of the Operating System, it is not an error of the computer technic, but it is an ideological error of the numeric systems. And it is an error of the conversion between the numeric systems. And there is no way to create more precise result in a 64 bit double precision system - without some rounding…
.
Yes, the 64 bit floating point system has an additional error (it is a real “computer technic related error”), but that error is smaller than the 32 bit single precision system system has.
.
The LibreOffice Calc can use only that basic arithmetical features what the computer technic, and the Operating System has/supports.

3 Likes