Bug 69701 - EDITING: Error in function GCD_ADD
Summary: EDITING: Error in function GCD_ADD
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.1.1.2 release
Hardware: Other Windows (All)
: medium normal
Assignee: Winfried Donkers
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-23 10:32 UTC by John Smith
Modified: 2015-06-02 05:30 UTC (History)
3 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 John Smith 2013-09-23 10:32:34 UTC
Problem description: Entering decimal values into GCD_ADD returns a wrong result when a value greater than 10 is entered.

Steps to reproduce:
1. In a default installation of LibreOffice, open an instance of Calc.
2. Open the Function Wizard
3. Double-click the GCD_ADD function to select it.
4. Enter values such as 2.1, 4.2, 6.4 and 10.5 into the Numbers list.

Current behavior:
The result returned is wrong. Remove the 10.5 value and the result is correctly given as 2.1.

Expected behavior:
The result of 2.1 should be returned for all the example values.
The input parameters are stated to be Numbers, not Integers.
              
Operating System: Windows XP
Version: 4.1.1.2 release
Comment 1 Stanislav Horacek 2013-09-23 16:19:04 UTC
GCD function works only for integers, as it is described in the ODF standard:
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part2.html#__RefHeading__1018532_715980110

or in Excel help:
http://office.microsoft.com/en-us/excel-help/gcd-HP005209104.aspx

GCD rounds input numbers down to integer and returns integers, but GCD_ADD apparently returns decimal values - maybe this is a bug.
Comment 2 John Smith 2013-09-23 20:00:23 UTC
Yes. No problem with GCD, only with GCD_ADD.
Comment 3 Stanislav Horacek 2013-09-24 13:20:59 UTC
OK, I confirm this as a bug: GCD_ADD function does not convert input values to integers and returns rationals. E.g.:
GCD_ADD(2.1;4.2) returns 2.1, should return 2
GCD(2.1;4.2) returns 2 correctly

This is probably inherited from OO - see also https://issues.apache.org/ooo/show_bug.cgi?id=71158 where the same behaviour (returning rationals) was corrected for GCD function.
Comment 4 Winfried Donkers 2015-03-31 08:27:58 UTC
The GCD_ADD function is present to offer compatibility with the Excel add-in function GCD from Excel 2003 and earlier (xls). 

The GCD function is fully ODFF1.2 compliant and is compatible with the Excel function GCD from Excel 200 and newer (xlsx).

Because GCD_ADD is an add-in function in Excel, it must be handled quite differently from GCD on export/import to/from Excel. Also, effectively, it is an outdated function, available only for backward compatibilty (xls). Patching this function seems to be a waste of time.

I will see if I can remove the GCD_ADD for the user, and substitute GCD with GCD_ADD when exporting to xls. When that is complete, all GCD_ADD uses from the past (in xls and in ods) will be automatically transferred to GCD.
The current behaviour is that GCD_ADD already is being substituted to GCD in ods, but GCD_ADD is still in the function list, so it's somewhat confusing.
Comment 5 Winfried Donkers 2015-06-02 05:30:23 UTC
No easy way to remove GCD_ADD from the user interface.
There are more add-in functions that only reside in Calc because of compatibility with xls, which is obsolete since 2003 when Microsoft introduced xlsx. (Gradually) removing these from the user interface is on my list, but not with the highest priority.

Given that:
 -GCD_ADD is an add-in function for import from xls documents,
 -GCD exports fine to xls,
 -GCD works correctly,
 -on import from xlsx GCD is used,
 -when using GCD_ADD in and ods document, it will be converted to GCD automatically,
I close this bug as 'WORKSFORME'.