Commit 88a9716c authored by Milo Yip's avatar Milo Yip

Merge pull request #89 from miloyip/issue88denormalnumber

Fix parsing numbers which are less than 1e-308
parents c4f64e7b 54566062
......@@ -796,7 +796,7 @@ private:
exp = s.Take() - '0';
while (s.Peek() >= '0' && s.Peek() <= '9') {
exp = exp * 10 + (s.Take() - '0');
if (exp > 308)
if (exp > 308 && !expMinus) // exp > 308 should be rare, so it should be checked first.
RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, s.Tell());
}
}
......
......@@ -137,6 +137,8 @@ TEST(Reader, ParseNumberHandler) {
TEST_DOUBLE("2.22507e-308", 2.22507e-308);
TEST_DOUBLE("-1.79769e+308", -1.79769e+308);
TEST_DOUBLE("-2.22507e-308", -2.22507e-308);
TEST_DOUBLE("4.9406564584124654e-324", 4.9406564584124654e-324); // minimum denormal
TEST_DOUBLE("1e-10000", 0.0); // must underflow
TEST_DOUBLE("18446744073709551616", 18446744073709551616.0); // 2^64 (max of uint64_t + 1, force to use double)
TEST_DOUBLE("-9223372036854775809", -9223372036854775809.0); // -2^63 - 1(min of int64_t + 1, force to use double)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment