Bug 148535 - Fraction formatting in Calc gives the wrong result
Summary: Fraction formatting in Calc gives the wrong result
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.2.6.2 release
Hardware: All macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-12 12:41 UTC by Rofo
Modified: 2022-04-15 05:28 UTC (History)
5 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 Rofo 2022-04-12 12:41:55 UTC
10% as a fraction gives you 1/9 instead 1/10.
Comment 1 sdc.blanco 2022-04-12 13:27:45 UTC
When Denominator Places is set to "2" (using Options for Fraction in Format Cells dialog), then it appears as 1/10.

Tested with 7.2.6.2 and 7.4.0.0+
Comment 2 Roman Kuznetsov 2022-04-13 20:30:59 UTC
Rofo your problem is solved by tip in Comment 1?
Comment 3 sdc.blanco 2022-04-15 01:03:25 UTC
@Rofo - I agree the behavior is surprising. But I believe it is by design.

https://help.libreoffice.org/master/en-US/text/scalc/guide/fraction_enter.html

If you use Format Cell (Numbers tab) notice that you can choose different predefined formats for fraction and immediately see the result in the preview window.

Notice also the "Format Code" control in the Numbers tab.  This shows the number codes used to define the format.  You can also make your own custom formats.

See:  https://help.libreoffice.org/master/en-US/text/shared/01/05020301.html

(where there is a special section on fractions)
Comment 4 Mike Kaganski 2022-04-15 05:28:16 UTC
As noted in comment 3, the documentation explains how to use the fraction feature properly; this specific case (1/10) is even mentioned there directly.

Just to reiterate: defining denominator number of digits, you define the "resolution" of the resulting number visual representation. It will never exceed that resolution (by using more digits than defined in the format); and using 1-digit denominator, you can approximate *any* value (1/9 being the best approximation for 0.1, as well as for any number greater than 1/18). OTOH, numerator would add as many digits as needed to represent that approximation - that way, "?/?" would give you "19/9" for "2.1" This behaves the same way as for decimal representation like "#.#", where the whole part would expand as needed, and fractional part would never expand.

Or put in other words: you must never expect to see the *exact* representation of any fractional number on screen, only some approximation according to the number format.