Bug 158353 - FILEOPEN XLSX Wrong round
Summary: FILEOPEN XLSX Wrong round
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.4.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
Depends on:
Blocks: XLSX
  Show dependency treegraph
 
Reported: 2023-11-24 10:27 UTC by Maxim Britov
Modified: 2024-06-02 11:25 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Simple sample (8.07 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2023-11-24 10:28 UTC, Maxim Britov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maxim Britov 2023-11-24 10:27:53 UTC
Description:
<v>57.374999999999993</v> and default format 0,00

Opens by:
LO >= 7.4 is 57.37
LO 7.3.7.2 is 57.38
Excel is 57.38


Actual Results:
57.37

Expected Results:
57.38


Reproducible: Always


User Profile Reset: No

Additional Info:
-
Comment 1 Maxim Britov 2023-11-24 10:28:48 UTC
Created attachment 191019 [details]
Simple sample

Open in with LO >=7.4 and in LO 7.3. See difference
Comment 2 Mike Kaganski 2023-11-24 11:20:05 UTC Comment hidden (obsolete)
Comment 3 Maxim Britov 2023-11-24 12:08:22 UTC
(In reply to Mike Kaganski from comment #2)
> 
> *** This bug has been marked as a duplicate of bug 158190 ***

Is this issue really dup of round() issue?
Here is not used round(). This is just a file from Excel.

1. Excel show 57.38 and LO show 57.37
2. If I change value, but restore 57.375 and save cell, I see 57.38
3. If I save and reopen I see 57.38
4. If I set option "Precision as shown" then =A1*100 will be 5738
   This is really wrong!
Comment 4 Mike Kaganski 2023-11-24 12:25:51 UTC
Yes you are right. It is different.

While rounding to 2 decimals here looks technically correct (it is smaller than 57.375), the problem of changing the value on save-and-reload is real.
Comment 5 Gabor Kelemen (allotropia) 2023-11-24 18:15:34 UTC
Seems to have started with:

https://git.libreoffice.org/core/+/9eb9083ff2fdaeb96399a0830a4394de4e29ef64

author	Mike Kaganski <mike.kaganski@collabora.com>	Tue Feb 15 09:20:52 2022 +0300
committer	Mike Kaganski <mike.kaganski@collabora.com>	Thu Feb 17 21:46:58 2022 +0100

Use Dragonbox to implement doubleTo*String*
Comment 6 Mike Kaganski 2023-11-24 20:03:49 UTC
(In reply to Gabor Kelemen (allotropia) from comment #5)
> Seems to have started with:

Started specifically what? The more numerically correct display, or the wrong save?
Comment 7 Gabor Kelemen (allotropia) 2023-11-27 12:25:34 UTC
(In reply to Mike Kaganski from comment #6)
> (In reply to Gabor Kelemen (allotropia) from comment #5)
> > Seems to have started with:
> 
> Started specifically what? The more numerically correct display, or the
> wrong save?

The fileopen difference on the attached file.
In 7.3 all 4 cells were displayed as 57.38
Since 7.4 the first two A1:A2 are 57.37 the second two A3:A4 are 57.38.
Did not check what happens after save.
Comment 8 ady 2023-11-27 17:44:18 UTC
(In reply to Gabor Kelemen (allotropia) from comment #7)
> Did not check what happens after save.

Please see comment 4. According to Mike, the problem is about either the file save or the file open, not really about the rounded result (57.37).
Comment 9 Thorsten Behrens (allotropia) 2024-03-02 03:13:13 UTC
(In reply to Mike Kaganski from comment #6)
> (In reply to Gabor Kelemen (allotropia) from comment #5)
> > Seems to have started with:
> 
> Started specifically what? The more numerically correct display, or the
> wrong save?

I guess for an XLSX file, the only correct way is to load & display it as Excel does?
Comment 10 Mike Kaganski 2024-03-02 03:20:31 UTC
(In reply to Thorsten Behrens (allotropia) from comment #9)

:-) It may be true, but completely orthogonal to the clarification requested in my question? ;-)
Comment 11 Mike Kaganski 2024-03-21 17:56:12 UTC
https://gerrit.libreoffice.org/c/core/+/165142 will take care of the display issue. However, let me make this issue strictly about the problem of wrong number roundtrip: the value of 57.374999999999993, that is stored in the original file, must stay 57.374999999999993 (or 57.37499999999999, which represents the same IEEE 754 64-bit binary value) on export, and must not be rounded to 57.375 in the file.
Comment 12 Mike Kaganski 2024-03-22 04:34:59 UTC
Aha: I already tried to fix the save problem in https://gerrit.libreoffice.org/c/core/+/151383 ...