Bug 59711 - EDITING: Function FLOOR misbehavior with negative numbers and positive significance
Summary: EDITING: Function FLOOR misbehavior with negative numbers and positive signif...
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.6.4.3 release
Hardware: Other Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-22 13:48 UTC by Filippo
Modified: 2013-09-18 11:50 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
Sample file (8.60 KB, application/xml)
2013-01-23 02:45 UTC, m_a_riosv
Details
Screenshot (4.33 KB, image/png)
2013-01-23 02:47 UTC, m_a_riosv
Details
Sample ODS file showing the bug (12.51 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-08-25 06:36 UTC, Aaron
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Filippo 2013-01-22 13:48:21 UTC
Problem description:
FLOOR function return "error 502" if passing a negative number and a positive significance: this has no sense, since even -12 is a multiple of 2.

Moreover, if one has data consisting in both positive and negative data, using FLOOR passing the same significance as argument for both positive and negative numbers increases the flexibility of the function, while keeping the meaning of the arguments as clear as possible.

Furthermore, such a behavior is consistent with the behavior of Excel.

It should be noted, that, if it's decided to keep the current behavior, "help" (https://help.libreoffice.org/Calc/Mathematical_Functions) files should be corrected to warn about the real meaning of the argument "significance".

From the help:
"Rounds a number down to the nearest multiple of Significance."

Steps to reproduce:
1. Type "=FLOOR(-12.5,-1)" in a cell in Calc

Current behavior:
Cell displays "error 502".

Expected behavior:
Cell value should be -13 or -12 if mode=1 is passed as argument. The same behavior is consistent with Excel(R).

              
Operating System: Windows 8
Version: 3.6.4.3 release
Comment 1 m_a_riosv 2013-01-23 02:45:55 UTC
Created attachment 73486 [details]
Sample file

Hi Filippo, thanks for reporting.

I can not reproduce the issue.
See the attached file and the screenshot.
Comment 2 m_a_riosv 2013-01-23 02:47:26 UTC
Created attachment 73487 [details]
Screenshot
Comment 3 Filippo 2013-01-23 07:23:28 UTC
I've made an error writing the formula, it's:
"=FLOOR(-12.5,1)"
negative number and positive significance.
Comment 4 Andreas J Guelzow 2013-04-25 01:24:37 UTC
Note that according to the ODF 1.2 (OpenFormula) specification the current behaviour of =FLOOR(-12.5,1) is correct. "Multiple" in this context means natural-number-multiple.

The real problem is that while the ODF specification allows the significance to be omitted, in which case it defaults to -1 if the first argument is negative and +1 if the first argument is positive, LibreOffice dos not implement this. That 1-argument version would then match the behaviour of the mathematical ceiling function.
Comment 5 Aaron 2013-08-25 06:36:22 UTC
Created attachment 84582 [details]
Sample ODS file showing the bug

Attached corrected sample file showing the bug. I note that in reading the ODF specification, nowhere does it say that "multiple" is restricted to positive integer multiples. Could someone explain how it could be interpreted in this way?

I agree with the original submitter in that allowing both positive and negative numbers increases the flexibility without any loss, and also improves compatibility with Excel.
Comment 6 Mike Kaganski 2013-09-18 11:50:53 UTC
(In reply to comment #5)
> I note that in reading the
> ODF specification, nowhere does it say that "multiple" is restricted to
> positive integer multiples. Could someone explain how it could be
> interpreted in this way?

OASIS Open Document Format for Office Applications (OpenDocument) Version 1.2 - Part 2: Recalculated Formula (OpenFormula) Format, part 6.17.3 FLOOR:

> Summary: Round a number N down to the nearest multiple of the second parameter, significance.
> Syntax: FLOOR( Number N [ ; [ Number significance ] [ ; Number mode ] ] )
> Returns: Number
> Constraints: Both N and significance shall be numeric and have the same sign.

The last cited clause, Constraints, gives the answer. So, NOTABUG. Unfortunately.