Bug 69068

Summary: RANK() function incorrectly ranking times
Product: LibreOffice Reporter: Moleskin Joe <moleskinjoe>
Component: CalcAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED WORKSFORME    
Severity: normal CC: afonit
Priority: medium    
Version: 4.0.5.2 release   
Hardware: x86 (IA32)   
OS: Windows (All)   
Whiteboard:
Crash report or crash signature: Regression By:
Attachments: Simple example of RANK() giving incorrect results.
Original sample modified.

Description Moleskin Joe 2013-09-07 13:33:35 UTC
Created attachment 85395 [details]
Simple example of RANK() giving incorrect results.

The RANK() function incorrectly ranks equal times generated by subtraction of one time from another.

For example 17:24, 17:35, 17:24, 17:21 should be ranked 2,4,2,1 not 2,4,3,1.

Suggested reason : although the times appear equal, the underlying numbers are different because of rounding.
Comment 1 m_a_riosv 2013-09-07 17:22:27 UTC
Created attachment 85403 [details]
Original sample modified.

Hi Moleskin, thanks for reporting.

Taking your sample, adding a ROUND() function in column D with decimal places referred to D1, you can see once the decimal places are beyond the computer precision RANK() function does not work but works properly with 16 decimal places or less.

Is needed round to get the formulas works as you want.

More useful information about the problem:
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
Comment 2 afonit 2014-06-24 18:12:25 UTC
I just opened the file in question and sorted on rank - it sorted properly.

I do not have libreoffice 4.1 as poster had, but I am using 4.2.5.2 on Fedora 20,
so I am going to change the status to Resolved,Worksforme.