summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-07-01 11:01:10 +0200
committerEike Rathke <erack@redhat.com>2016-07-01 11:47:31 +0200
commit415cd81d90aa5dd4f9a5d914fabd4c2371f53e4c (patch)
tree05035e7b57e5962cd83047acad71d2717c671ef1
parent3a944846a8460e33fc0cb79f38823e503fb1385c (diff)
let GetInt*() truncate to integer towards 0
like it should always had been the case ... Change-Id: I75b9e71bbaad5e356a45b416a3b42dc4becec801
-rw-r--r--sc/source/core/tool/interpr4.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 1421f87fcfb0..dd05982ff5f3 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2095,7 +2095,11 @@ double ScInterpreter::GetDoubleWithDefault(double nDefault)
sal_Int32 ScInterpreter::GetInt32()
{
- double fVal = rtl::math::approxFloor( GetDouble());
+ double fVal = GetDouble();
+ if (fVal > 0.0)
+ fVal = rtl::math::approxFloor( fVal);
+ else if (fVal < 0.0)
+ fVal = rtl::math::approxCeil( fVal);
if (fVal < SAL_MIN_INT32 || fVal > SAL_MAX_INT32)
{
SetError( errIllegalArgument);
@@ -2106,7 +2110,11 @@ sal_Int32 ScInterpreter::GetInt32()
sal_Int32 ScInterpreter::GetInt32WithDefault( sal_Int32 nDefault )
{
- double fVal = rtl::math::approxFloor( GetDoubleWithDefault( nDefault));
+ double fVal = GetDoubleWithDefault( nDefault);
+ if (fVal > 0.0)
+ fVal = rtl::math::approxFloor( fVal);
+ else if (fVal < 0.0)
+ fVal = rtl::math::approxCeil( fVal);
if (fVal < SAL_MIN_INT32 || fVal > SAL_MAX_INT32)
{
SetError( errIllegalArgument);
@@ -2117,7 +2125,11 @@ sal_Int32 ScInterpreter::GetInt32WithDefault( sal_Int32 nDefault )
sal_Int16 ScInterpreter::GetInt16()
{
- double fVal = rtl::math::approxFloor( GetDouble());
+ double fVal = GetDouble();
+ if (fVal > 0.0)
+ fVal = rtl::math::approxFloor( fVal);
+ else if (fVal < 0.0)
+ fVal = rtl::math::approxCeil( fVal);
if (fVal < SAL_MIN_INT16 || fVal > SAL_MAX_INT16)
{
SetError( errIllegalArgument);