summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-09-04 12:57:16 +0200
committerEike Rathke <erack@redhat.com>2017-09-04 12:57:52 +0200
commit9e694c747954078442d47d3d7bd1d4db283b96ff (patch)
tree40d5e51b821d21965a5674ae38fe7bf08d70b4a6 /sc/source
parent04749a1115a44ce7a2d05c1ea6c23613feded5f9 (diff)
Resolves: tdf#103734 propagate error from matrix to MIN()/MAX()
Change-Id: I1ebc5baf4957ef9e3d1477b803cf7fee02754360
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/tool/interpr1.cxx8
-rw-r--r--sc/source/core/tool/scmatrix.cxx8
2 files changed, 14 insertions, 2 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 1b1ba4f703a6..78a7e6311b68 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -3631,7 +3631,9 @@ void ScInterpreter::ScMin( bool bTextAsZero )
}
else
{
- if ( nVal < nMin )
+ if (!rtl::math::isFinite(nVal))
+ PushError( GetDoubleErrorValue( nVal));
+ else if ( nVal < nMin )
PushDouble(0.0); // zero or only empty arguments
else
PushDouble(nMin);
@@ -3786,7 +3788,9 @@ void ScInterpreter::ScMax( bool bTextAsZero )
}
else
{
- if ( nVal > nMax )
+ if (!rtl::math::isFinite(nVal))
+ PushError( GetDoubleErrorValue( nVal));
+ else if ( nVal > nMax )
PushDouble(0.0); // zero or only empty arguments
else
PushDouble(nMax);
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 6e0e9bb7b69b..27836073b491 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1390,6 +1390,10 @@ struct MaxOp
static double init() { return -std::numeric_limits<double>::max(); }
static double compare(double left, double right)
{
+ if (!rtl::math::isFinite(left))
+ return left;
+ if (!rtl::math::isFinite(right))
+ return right;
return std::max(left, right);
}
@@ -1408,6 +1412,10 @@ struct MinOp
static double init() { return std::numeric_limits<double>::max(); }
static double compare(double left, double right)
{
+ if (!rtl::math::isFinite(left))
+ return left;
+ if (!rtl::math::isFinite(right))
+ return right;
return std::min(left, right);
}