Download it now!
Bug 100594 - Number format fraction: forced denominator gives wrong result
Summary: Number format fraction: forced denominator gives wrong result
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.3.7.2 release
Hardware: All All
: medium normal
Assignee: Laurent BP
URL:
Whiteboard: target:5.3.0
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-24 16:40 UTC by Laurent BP
Modified: 2016-10-25 18:54 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 Laurent BP 2016-06-24 16:40:05 UTC
Description: Forced denominator higher than 14 and one '?' for numerator gives wrong fraction

Steps to reproduce:
1. Format > Cells > Numbers, User format # ?/100
2. Enter values such from 0.01 to 0.2 each 1%

Actual behavior:
Values between 1% and 5% are displayed: 0
Values between 6% and 11% are displayed: 11/100
Values between 12% and 13% are displayed: 12/100
and so on

Expected behavior:
Values should be displayed 1/100 to 20/100

The problem is due to the fact that Forced Denominator fraction is calculated not from the value, but from nFrac/nDiv which is a rounded value
http://opengrok.libreoffice.org/xref/core/svl/source/numbers/zformat.cxx#lcl_ForcedDenominator

nFrac and nDiv are calculated just before in
http://opengrok.libreoffice.org/xref/core/svl/source/numbers/zformat.cxx#ImpGetFractionOutput
with ?/? as format
Comment 1 Buovjaga 2016-06-26 13:28:43 UTC
Reproduced.

Arch Linux 64-bit, KDE Plasma 5
Version: 5.3.0.0.alpha0+
Build ID: ff25ea3d5ccf3a990767cbb1ef99037d3f84b072
CPU Threads: 8; OS Version: Linux 4.6; UI Render: default; 
Locale: fi-FI (fi_FI.UTF-8)
Built on June 26th 2016
Comment 2 Commit Notification 2016-06-29 18:32:07 UTC
Laurent Balland-Poirier committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=97fda453bc43fbae3d0a9fd05259e92d3205fd06

tdf#100594 Calculate nFrac with fNumber for Forced Denominator

It will be available in 5.3.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 3 Commit Notification 2016-07-06 09:55:33 UTC
Laurent Balland-Poirier committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=37d97ff389d0941b32405f3433d2e595e10c76ab

tdf#99996 tdf#100594 tdf#100754 Add qa unit test

It will be available in 5.3.0.

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

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