[Libreoffice-commits] core.git: sc/source
Winfried Donkers
winfrieddonkers at libreoffice.org
Tue Jan 3 21:10:17 UTC 2017
sc/source/core/tool/interpr3.cxx | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
New commits:
commit facb4e69e4c75839df89969206403d2e97146dbd
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date: Sat Dec 31 10:05:46 2016 +0100
tdf#104981 Fix deficiencies with PERCENTRANK functions.
Added constraint check for significance argument.
Replced inproper use of log() with log10().
Improved code efficiency a little bit.
Change-Id: Ie918857e6a04ea9fcf18410f789d7252f9c1cfc8
Reviewed-on: https://gerrit.libreoffice.org/32528
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 205e1aa..c0ac545 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3498,6 +3498,11 @@ void ScInterpreter::ScPercentrank( bool bInclusive )
if ( !MustHaveParamCount( nParamCount, 2, 3 ) )
return;
double fSignificance = ( nParamCount == 3 ? ::rtl::math::approxFloor( GetDouble() ) : 3.0 );
+ if ( fSignificance < 1.0 )
+ {
+ PushIllegalArgument();
+ return;
+ }
double fNum = GetDouble();
vector<double> aSortArray;
GetSortArray( 1, aSortArray, nullptr, false, false );
@@ -3517,8 +3522,8 @@ void ScInterpreter::ScPercentrank( bool bInclusive )
fRes = GetPercentrank( aSortArray, fNum, bInclusive );
if ( fRes != 0.0 )
{
- double fExp = ::rtl::math::approxFloor( log( fRes ) );
- fRes = ::rtl::math::round( fRes * pow( 10, -fExp + fSignificance - 1 ) ) / pow( 10, -fExp + fSignificance - 1 );
+ double fExp = ::rtl::math::approxFloor( log10( fRes ) ) + 1.0 - fSignificance;
+ fRes = ::rtl::math::round( fRes * pow( 10, -fExp ) ) / pow( 10, -fExp );
}
PushDouble( fRes );
}
More information about the Libreoffice-commits
mailing list