summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <geert.bosch@mongodb.com>2019-10-17 16:17:40 +0000
committerevergreen <evergreen@mongodb.com>2019-10-17 16:17:40 +0000
commit5e9a5647539b661e00d9417face72abbaa289aa8 (patch)
tree36ba9c4c57c46a6cee952347207299833fe378bb
parent684e936937f04afbd9cd0d5a619c7604fc99f0f8 (diff)
downloadmongo-5e9a5647539b661e00d9417face72abbaa289aa8.tar.gz
SERVER-43034 Correctly deal with infinite results in DoubleDoubleSummation
(cherry picked from commit 9d31de1d5458e865439e643eb75f719d5217d064)
-rw-r--r--src/mongo/util/summation.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mongo/util/summation.h b/src/mongo/util/summation.h
index 1da8efe4bb1..d199fc304a7 100644
--- a/src/mongo/util/summation.h
+++ b/src/mongo/util/summation.h
@@ -91,9 +91,9 @@ public:
* Summations of even extremely long series of 32-bit and 64-bit integers should be exact.
*/
Decimal128 getDecimal() const {
- return std::isnan(_sum) ? Decimal128(_special, Decimal128::kRoundTo34Digits)
- : Decimal128(_sum, Decimal128::kRoundTo34Digits)
- .add(Decimal128(_addend, Decimal128::kRoundTo34Digits));
+ return !std::isfinite(_sum) ? Decimal128(_special, Decimal128::kRoundTo34Digits)
+ : Decimal128(_sum, Decimal128::kRoundTo34Digits)
+ .add(Decimal128(_addend, Decimal128::kRoundTo34Digits));
}
/**