diff options
author | Geert Bosch <geert@mongodb.com> | 2016-03-31 00:42:05 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2016-04-22 15:00:29 -0400 |
commit | b5282c3b6d17a8b11e432ca5fbbfde5caddea048 (patch) | |
tree | 2205f7d457f0a1b7b278f8b723c5820c642d556d /src/mongo/platform/decimal128.cpp | |
parent | 8e13345122986b242811ebee1c0908a4fc01640c (diff) | |
download | mongo-b5282c3b6d17a8b11e432ca5fbbfde5caddea048.tar.gz |
SERVER-19703 Add KeyString support for NumberDecimal
Diffstat (limited to 'src/mongo/platform/decimal128.cpp')
-rw-r--r-- | src/mongo/platform/decimal128.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/mongo/platform/decimal128.cpp b/src/mongo/platform/decimal128.cpp index ddaa381b367..990b18e1569 100644 --- a/src/mongo/platform/decimal128.cpp +++ b/src/mongo/platform/decimal128.cpp @@ -223,7 +223,7 @@ Decimal128::Decimal128(double doubleValue, // Estimate doubleValue's base10 exponent from its base2 exponent by // multiplying by an approximation of log10(2). // Since 10^(x*log10(2)) == 2^x, this initial guess gets us very close. - int base10Exp = (base2Exp * 301) / 1000; + int base10Exp = (base2Exp * 30103) / (100 * 1000); // Although both 1000 and .001 have a base 10 exponent of magnitude 3, they have // a different number of leading/trailing zeros. Adjust base10Exp to compensate. @@ -244,6 +244,7 @@ Decimal128::Decimal128(double doubleValue, } // The decimal must have exactly 15 digits of precision + invariant(getCoefficientHigh() == 0); invariant(_value.low64 >= 100000000000000ull && _value.low64 <= 999999999999999ull); } @@ -566,11 +567,6 @@ Decimal128 Decimal128::quantize(const Decimal128& reference, return result; } -Decimal128 Decimal128::normalize() const { - // Normalize by adding 0E-6176 which forces a decimal to maximum precision (34 digits) - return add(kLargestNegativeExponentZero); -} - bool Decimal128::isEqual(const Decimal128& other) const { std::uint32_t throwAwayFlag = 0; BID_UINT128 current = decimal128ToLibraryType(_value); |