Return 0 if binary exponent is too small
This commit is contained in:
parent
f5e5d47fac
commit
4e9b4f6d6a
@ -142,7 +142,10 @@ struct DiyFp {
|
||||
uint64_t u64;
|
||||
}u;
|
||||
RAPIDJSON_ASSERT(f <= kDpHiddenBit + kDpSignificandMask);
|
||||
RAPIDJSON_ASSERT(e >= kDpDenormalExponent);
|
||||
if (e < kDpDenormalExponent) {
|
||||
// Underflow.
|
||||
return 0.0;
|
||||
}
|
||||
RAPIDJSON_ASSERT(e < kDpMaxExponent);
|
||||
const uint64_t be = (e == kDpDenormalExponent && (f & kDpHiddenBit) == 0) ? 0 :
|
||||
static_cast<uint64_t>(e + kDpExponentBias);
|
||||
|
@ -392,6 +392,15 @@ static void TestParseDouble() {
|
||||
"83723677529752585477247372368372368547354737253685475529752",
|
||||
6223372036854775808.0);
|
||||
|
||||
|
||||
TEST_DOUBLE(fullPrecision, "1e-325", 0.0);
|
||||
TEST_DOUBLE(fullPrecision, "1e-324", 0.0);
|
||||
TEST_DOUBLE(fullPrecision, "2e-324", 0.0);
|
||||
TEST_DOUBLE(fullPrecision, "2.4703282292062327e-324", 0.0);
|
||||
TEST_DOUBLE(fullPrecision, "2.4703282292062328e-324", 2.4703282292062328e-324);
|
||||
TEST_DOUBLE(fullPrecision, "2.48e-324", 2.48e-324);
|
||||
TEST_DOUBLE(fullPrecision, "2.5e-324", 2.5e-324);
|
||||
|
||||
#undef TEST_DOUBLE
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user