summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeert Bosch <geert.bosch@mongodb.com>2019-10-17 16:19:37 +0000
committerevergreen <evergreen@mongodb.com>2019-10-17 16:19:37 +0000
commit8d959c8cd455cbf69c0c3681839695c0ebc25a84 (patch)
tree7d384da4920fdfa2466f5f9d2a9818cf4a04f6d6 /src
parent6d06698f139230feb43fb4ee56867f3b8ddf51a8 (diff)
downloadmongo-8d959c8cd455cbf69c0c3681839695c0ebc25a84.tar.gz
SERVER-43034 Correctly deal with infinite results in DoubleDoubleSummation
(cherry picked from commit 9d31de1d5458e865439e643eb75f719d5217d064)
Diffstat (limited to 'src')
-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 3ca36801b5b..5132d1cd581 100644
--- a/src/mongo/util/summation.h
+++ b/src/mongo/util/summation.h
@@ -92,9 +92,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));
}
/**