diff options
author | Geert Bosch <geert@mongodb.com> | 2016-09-20 13:50:13 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2016-09-29 16:49:46 -0400 |
commit | 251a6f637b425c726aa2899b6d3bbf3c2be8aa98 (patch) | |
tree | 6d1e9a01b3d2aca5991f73be1cdec0f83b79e2d8 /src/mongo/platform/decimal128_test.cpp | |
parent | d0f2988f1cc09af039fd62d68a0c631f9241d579 (diff) | |
download | mongo-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.cpp | 7 |
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); |