summaryrefslogtreecommitdiff
path: root/src/mongo/platform/decimal128_test.cpp
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2016-09-20 13:50:13 -0400
committerGeert Bosch <geert@mongodb.com>2016-09-29 16:49:46 -0400
commit251a6f637b425c726aa2899b6d3bbf3c2be8aa98 (patch)
tree6d1e9a01b3d2aca5991f73be1cdec0f83b79e2d8 /src/mongo/platform/decimal128_test.cpp
parentd0f2988f1cc09af039fd62d68a0c631f9241d579 (diff)
downloadmongo-251a6f637b425c726aa2899b6d3bbf3c2be8aa98.tar.gz
SERVER-26193 Fix incorrect rounding in double to decimal conversion
Diffstat (limited to 'src/mongo/platform/decimal128_test.cpp')
-rw-r--r--src/mongo/platform/decimal128_test.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/platform/decimal128_test.cpp b/src/mongo/platform/decimal128_test.cpp
index a9f09aa893f..eea0480780e 100644
--- a/src/mongo/platform/decimal128_test.cpp
+++ b/src/mongo/platform/decimal128_test.cpp
@@ -202,6 +202,13 @@ TEST(Decimal128Test, TestDoubleConstructorMaxRoundUp) {
ASSERT_EQUALS(d.toString(), "1.79769313486232E+308");
}
+TEST(Decimal128Test, TestDoubleConstructorRoundAllNines) {
+ double allNines = 0.999999999999999; // 15 nines
+ Decimal128 d(
+ allNines, Decimal128::kRoundTo15Digits, Decimal128::RoundingMode::kRoundTiesToAway);
+ ASSERT_EQUALS(d.toString(), "0.999999999999999"); // 15 nines
+}
+
TEST(Decimal128Test, TestDoubleConstructorMaxNeg) {
double doubleMax = -1 * DBL_MAX;
Decimal128 d(doubleMax);