Bug 153887 - So-called improper fractions are badly formatted with a fix denominator to "0/0" under a certain condition.
Summary: So-called improper fractions are badly formatted with a fix denominator to "0...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.3.0.3 release
Hardware: All All
: medium normal
Assignee: Laurent Balland
URL:
Whiteboard: target:7.6.0 target:7.5.3 target:7.4.7
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-28 20:17 UTC by Wolfgang Jäger
Modified: 2023-04-07 16:38 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Jäger 2023-02-28 20:17:46 UTC
Number formatting supports fixed denominators and so-called improper fractions without splitting off the integer part. A respective format code is e.g. "?/8". 
If the formatting requires the roundig UP to an integer, the diplayed result is 0/0. 

Example: 
1.995 formatted using the code ?/8 results in 0/0.
The expected correct result would be 16/8. 

The error is bound to the AMOUNT of the input, and does not occur if the integer result to show is obtained by rounding DOWN. 

This seems to be a regression introduced with V 5.3. 
That version implemented a new algorithm for fractional formatting. That algorithm should, however, not be related to the reported bug. It only provides the raw result. If an integer part is split off or not should occur later. 
Cf tdf#99996 .

Older versions don't show the bug.

Support for fix demominators was introduced verty early in LibO, but was not heritage.
Comment 1 Laurent Balland 2023-03-04 09:24:15 UTC
Confirmed with Version: 7.5.0.3 (X86_64) / LibreOffice Community
Build ID: c21113d003cd3efa8c53188764377a8272d9d6de
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
Calc: threaded
Comment 2 Laurent Balland 2023-03-19 12:07:50 UTC
Reproduce with free denominator as well
1. Enter value 1.95
2. Format as ?/? (no integer part)

Actual result:
0/0

Expected result:
2/1

No problem if value is 2 or slightly above like 2.001. Bug occurs when value is below integer.
No change if other digit codes (# or 0) are used to create fraction format.
Comment 3 Laurent Balland 2023-03-19 14:28:34 UTC
I think the bug was introduced by
https://cgit.freedesktop.org/libreoffice/core/commit/svl/source/numbers/zformat.cxx?id=5706b29974c1c3ab0ba5a23685accf2fbebc3e06


https://opengrok.libreoffice.org/xref/core/svl/source/numbers/zformat.cxx?r=2cb2e2b9#2891
nDiv should not be reset to 0, but to 1 or forced denominator

unfortunately, all our unit tests round down the value, so this bug was not detected.
Comment 4 Commit Notification 2023-04-06 16:01:01 UTC
Laurent Balland committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/dc9b8c31aaf72812dc205f610638098898a4cde7

tdf#153887 Fraction number format: avoid 0/0

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2023-04-07 01:04:58 UTC
Laurent Balland committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/072f84001b2d28915085909a4d9a5a52bd7f6b61

tdf#153887 Fraction number format: avoid 0/0

It will be available in 7.5.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2023-04-07 16:38:38 UTC
Laurent Balland committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/40beefc591d8417f1291834fe66a348678241820

tdf#153887 Fraction number format: avoid 0/0

It will be available in 7.4.7.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.