21 RAPIDJSON_DIAG_OFF(unreachable-code)
24 #define BIGINTEGER_LITERAL(s) BigInteger(s, sizeof(s) - 1) 28 TEST(Strtod, CheckApproximationCase) {
29 static const int kSignificandSize = 52;
30 static const int kExponentBias = 0x3FF;
42 u.u = 0x465a72e467d88 | ((
static_cast<uint64_t>(-149 + kExponentBias)) << kSignificandSize);
44 const uint64_t bInt = (u.u & kSignificandMask) | kHiddenBit;
45 const int bExp =
static_cast<int>(((u.u & kExponentMask) >> kSignificandSize) - kExponentBias - kSignificandSize);
46 EXPECT_DOUBLE_EQ(1.7864e-45, b);
48 EXPECT_EQ(-201, bExp);
51 const char dInt[] =
"17864";
55 const int hExp = bExp - 1;
56 EXPECT_EQ(-202, hExp);
94 int common_Exp2 = std::min(dS_Exp2, std::min(bS_Exp2, hS_Exp2));
95 dS_Exp2 -= common_Exp2;
96 bS_Exp2 -= common_Exp2;
97 hS_Exp2 -= common_Exp2;
99 EXPECT_EQ(153, dS_Exp2);
100 EXPECT_EQ(0, dS_Exp5);
101 EXPECT_EQ(1, bS_Exp2);
102 EXPECT_EQ(49, bS_Exp5);
103 EXPECT_EQ(0, hS_Exp2);
104 EXPECT_EQ(49, hS_Exp5);
107 dS.MultiplyPow5(static_cast<unsigned>(dS_Exp5)) <<=
static_cast<size_t>(dS_Exp2);
110 bS.MultiplyPow5(static_cast<unsigned>(bS_Exp5)) <<=
static_cast<size_t>(bS_Exp2);
113 hS.MultiplyPow5(static_cast<unsigned>(hS_Exp5)) <<=
static_cast<size_t>(hS_Exp2);
115 EXPECT_TRUE(
BIGINTEGER_LITERAL(
"203970822259994138521801764465966248930731085529088") == dS);
116 EXPECT_TRUE(
BIGINTEGER_LITERAL(
"203970822259994122305215569213032722473144531250000") == bS);
119 EXPECT_EQ(1, dS.Compare(bS));
122 EXPECT_FALSE(dS.Difference(bS, &delta));
124 EXPECT_TRUE(bS.Difference(dS, &delta));
127 EXPECT_EQ(-1, delta.Compare(hS));
#define BIGINTEGER_LITERAL(s)
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
unsigned __int64 uint64_t
TEST(Strtod, CheckApproximationCase)