tdf#100843 LCM_EXCEL2003 fix incorrect handling of non-integer values.

Non-integer values should be truncated as Excel does.
Also, make the function return an error with negative values.

Change-Id: I6a8ce1fb82d20294d9398ca2af308f88b51d5e82
Reviewed-on: https://gerrit.libreoffice.org/27096
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
Winfried Donkers
2016-07-11 10:04:12 +02:00
committed by Eike Rathke
parent 3d76efdaad
commit 09f6bfadad

View File

@@ -738,18 +738,22 @@ double SAL_CALL AnalysisAddIn::getLcm( const uno::Reference< beans::XPropertySet
if( aValList.Count() == 0 )
return 0.0;
double f = aValList.Get(0);
double f = rtl::math::approxFloor( aValList.Get(0) );
if( f < 0.0 )
throw lang::IllegalArgumentException();
if( f == 0.0 )
return f;
for( sal_uInt32 i = 1; i < aValList.Count(); ++i )
{
double fTmp = aValList.Get(i);
double fTmp = rtl::math::approxFloor( aValList.Get(i) );
if( fTmp < 0.0 )
throw lang::IllegalArgumentException();
f = fTmp * f / GetGcd( fTmp, f );
if( f == 0.0 )
return f;
else
f = fTmp * f / GetGcd( fTmp, f );
}
RETURN_FINITE( f );