Created attachment 186044 [details] The said file See the attached file where I do =-50+49,6-48+48,34-43+43,06 If the calculation is done all in a single step, it correctly says the result is 0 If done in several steps it says the result is 7,105427357601E-15 Version: 7.5.1.2 (X86_64) / LibreOffice Community Build ID: 50(Build:2) CPU threads: 12; OS: Linux 6.2; UI render: default; VCL: kf5 (cairo+xcb) Locale: ca-ES (ca_ES.UTF-8); UI: ca-ES 7.5.1-1 Calc: threaded
This is not a bug. Floating-point calculations in Calc are imprecise by nature [1]. Every single calculation may (and in most cases does) create a calculation error; sum of these errors would usually be non-0. However, there are ways to account for the error *inside a series of calculations* - such as Kahan algorithm and its variations [2]. Note that it can only increase precision when during the series of calculations, not only the intermediate results are stored (which have errors every time), but also separate values of errors, which are combined independently, and are added to the final result of the main sum. Such an algorithm had been implemented in Calc in version 7.2 (bug 137679). So now the calculations that are performed together can benefit from that. But calculations that store intermediate results separately, obviously loose the error information. [1] https://wiki.documentfoundation.org/Faq/Calc/Accuracy [2] https://en.wikipedia.org/wiki/Kahan_summation_algorithm
I sorry but this is a somewhat weak answer. Yes, floating point arithmetic is "broken", but as you said, Libreoffice knows how to do it correctly when doing the calculation in one step, so well, do the calculation in one step ;) The intermediate results are formulas, there's nothing preventing Calc from evaluating the final formula completely instead of using the already pre-calculated intermediate results. (Speaking from the "I know nothing about this code" point of view obviously, when i say "there's nothing" i mean "in theory it should be possible", no idea how hard it'd be or not in practice)
No. It would mean that a change somewhere in the chain would result in complete recalculation, including cells before the changed cell. This is not an option. If one needs increased precision, one needs to use respective formula.