Return infinity if binary exponent is too large
This commit is contained in:
parent
7acbb87c2b
commit
cb009f3050
@ -20,6 +20,7 @@
|
|||||||
#define RAPIDJSON_DIYFP_H_
|
#define RAPIDJSON_DIYFP_H_
|
||||||
|
|
||||||
#include "../rapidjson.h"
|
#include "../rapidjson.h"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__INTEL_COMPILER)
|
#if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__INTEL_COMPILER)
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
@ -146,7 +147,10 @@ struct DiyFp {
|
|||||||
// Underflow.
|
// Underflow.
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
RAPIDJSON_ASSERT(e < kDpMaxExponent);
|
if (e >= kDpMaxExponent) {
|
||||||
|
// Overflow.
|
||||||
|
return std::numeric_limits<double>::infinity();
|
||||||
|
}
|
||||||
const uint64_t be = (e == kDpDenormalExponent && (f & kDpHiddenBit) == 0) ? 0 :
|
const uint64_t be = (e == kDpDenormalExponent && (f & kDpHiddenBit) == 0) ? 0 :
|
||||||
static_cast<uint64_t>(e + kDpExponentBias);
|
static_cast<uint64_t>(e + kDpExponentBias);
|
||||||
u.u64 = (f & kDpSignificandMask) | (be << kDpSignificandSize);
|
u.u64 = (f & kDpSignificandMask) | (be << kDpSignificandSize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user