summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorWinfried Donkers <winfrieddonkers@libreoffice.org>2016-07-11 10:04:12 +0200
committerEike Rathke <erack@redhat.com>2016-07-11 14:55:04 +0000
commit09f6bfadad0be9ebe24abcde1876a0b2d0c9fd97 (patch)
tree3f2b5aef4d0e4b7034f60c5ec0f179c4f0d15dbb /scaddins
parent3d76efdaad84e288e5e85b4f25e69892fec12f25 (diff)
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>
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/source/analysis/analysis.cxx12
1 files changed, 8 insertions, 4 deletions
diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx
index 0cd5d7982d8b..a8d9be1cb194 100644
--- a/scaddins/source/analysis/analysis.cxx
+++ b/scaddins/source/analysis/analysis.cxx
@@ -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 );