Bug 155646

Summary: Decimal calculations are subject to binary float error
Product: LibreOffice Reporter: Michael Whapples <mwhapples>
Component: CalcAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED NOTABUG    
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Windows (All)   
Whiteboard:
Crash report or crash signature: Regression By:

Description Michael Whapples 2023-06-02 10:27:04 UTC
In any cell in LibreOffice enter the following formula =1475.99-1440.32 and observe the output.
Expected: 35.67
Actual: 35.6700000000001
It appears LibreOffice is subject to the float errors found in primitive data types in most programming languages. As a Java developer I am aware of this float issue and how in Java BigDecimal is used for accurate decimal calculations. However in a spreadsheet I would expect accurate decimal calculation by default and this is the case with tools like excel or google sheets.
Even worse is that if I change the cell format to currency I still observe this float error. It is worse as currency typically should be using accurate decimal calculations, I cannot think of a case when currency should use binary float types.
The version of LibreOffice calc I have tested is 7.5.3.2.
Comment 2 Mike Kaganski 2023-06-02 11:06:41 UTC
(In reply to Michael Whapples from comment #0)
> and this is the case with tools like excel or google sheets.

This statement is wrong. Just add enough decimals to the cell format to see the real value there.