Bug 149392 - Simple calculation error
Summary: Simple calculation error
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-31 06:38 UTC by John Maguire
Modified: 2022-05-31 12:18 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Simple calc sheet (28.32 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-05-31 06:42 UTC, John Maguire
Details
Calculation using ROUND function (28.73 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-05-31 12:16 UTC, Rafael Lima
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Maguire 2022-05-31 06:38:26 UTC
Description:
I create monthly reports for my club. We use a credit card processor to accept payments for dues and other items.
Last month, I noticed an error when reconciling the report against the bank statement. Thankfully, it was a small error.
This month the error was larger since more dues were paid.
By comparing the CC processor's data with the report, there was a discrepancy in the calculation for $25.00. There was no error for more or fewer sums. Just $25.00

I've included a link to the simple calc sheet that describes the error.

https://bit.ly/3abVtZe

Steps to Reproduce:
1. Four columns (no labels)
2. First column enter 25
3. Second column enter =A1*0.029+0.3
4. Second column calculates the number 1.03
5. Third column subtract value =A1-A2


Actual Results:
The third column should be 23.97, yet it calculates to equal 23.98

Expected Results:
The third column should be 23.97


Reproducible: Always


User Profile Reset: No



Additional Info:
How to attach file?

See my calc sample: https://bit.ly/3abVtZe

DOES NOT WORK:

https://wiki.documentfoundation.org/UserProfile#Resolving_corruption_in_the_user_profile 

https://wiki.documentfoundation.org/OpenGL#How_to_enable.2Fdisable_OpenGL
Comment 1 John Maguire 2022-05-31 06:42:00 UTC
Created attachment 180485 [details]
Simple calc sheet
Comment 2 Rafael Lima 2022-05-31 12:13:09 UTC
Hi John, thanks for reporting.

The reason this is happening is due to how numbers are rounded when you reduce the number of decimal digits shown. In your example, if you showed 3 decimal places you would have.

1.025 (in the 2nd column) and 23.975 (in the 3rd column)

If you select these values and ask LO to show only two decimal places, it will show

1.03 (in the 2nd column) and 23.98 (in the 3rd column)

But keep in mind that internally the values are still 1.025 and 23.975. You only changed what is being shown, you did not change the actual value. So the calculation is correct.

You can try rounding Column C with 2 decimal places in your document before the subtraction in column D.
Comment 3 Rafael Lima 2022-05-31 12:16:31 UTC
Created attachment 180500 [details]
Calculation using ROUND function

In this file I used the Round function in column C.

Beware though that the banking system in your country may use different rounding rules. You need to check which rounding rules they're using.

Rounding numbers in banks has always been a problem. See:

https://en.wikipedia.org/wiki/Cash_rounding
Comment 4 Rafael Lima 2022-05-31 12:18:49 UTC
Setting this as NOTABUG since calculation results are correct.