23 #ifndef RAPIDJSON_DIYFP_H_ 24 #define RAPIDJSON_DIYFP_H_ 27 #include "../rapidjson.h" 30 #if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__INTEL_COMPILER) 32 #pragma intrinsic(_umul128) 40 RAPIDJSON_DIAG_OFF(effc++)
45 RAPIDJSON_DIAG_OFF(padded)
74 #if defined(_MSC_VER) && defined(_M_AMD64) 79 return DiyFp(h,
e + rhs.
e + 64);
80 #elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && \ 82 __extension__
typedef unsigned __int128 uint128;
83 uint128 p =
static_cast<uint128
>(
f) * static_cast<uint128>(rhs.
f);
88 return DiyFp(h,
e + rhs.
e + 64);
99 uint64_t tmp = (bd >> 32) + (ad & M32) + (bc & M32);
101 return DiyFp(ac + (ad >> 32) + (bc >> 32) + (tmp >> 32),
e + rhs.
e + 64);
122 DiyFp pl =
DiyFp((
f << 1) + 1,
e - 1).NormalizeBoundary();
125 mi.
f <<= mi.
e - pl.
e;
143 return std::numeric_limits<double>::infinity();
171 static const uint64_t kCachedPowers_F[] = {
259 static const int16_t kCachedPowers_E[] = {
260 -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, -954,
261 -927, -901, -874, -847, -821, -794, -768, -741, -715, -688, -661,
262 -635, -608, -582, -555, -529, -502, -475, -449, -422, -396, -369,
263 -343, -316, -289, -263, -236, -210, -183, -157, -130, -103, -77,
264 -50, -24, 3, 30, 56, 83, 109, 136, 162, 189, 216,
265 242, 269, 295, 322, 348, 375, 402, 428, 455, 481, 508,
266 534, 561, 588, 614, 641, 667, 694, 720, 747, 774, 800,
267 827, 853, 880, 907, 933, 960, 986, 1013, 1039, 1066};
269 return DiyFp(kCachedPowers_F[index], kCachedPowers_E[index]);
274 double dk = (-61 -
e) * 0.30102999566398114 +
276 int k =
static_cast<int>(dk);
277 if (dk - k > 0.0) k++;
279 unsigned index =
static_cast<unsigned>((k >> 3) + 1);
280 *K = -(-348 +
static_cast<int>(
288 unsigned index =
static_cast<unsigned>(exp + 348) / 8u;
289 *outExp = -348 +
static_cast<int>(index) * 8;
299 RAPIDJSON_DIAG_OFF(padded)
305 #endif // RAPIDJSON_DIYFP_H_
#define RAPIDJSON_ASSERT(x)
Assertion.
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
static const int kDpExponentBias
DiyFp GetCachedPower10(int exp, int *outExp)
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
static const int kDiySignificandSize
DiyFp(uint64_t fp, int exp)
static const int kDpMaxExponent
static const uint64_t kDpSignificandMask
unsigned __int64 uint64_t
static const int kDpDenormalExponent
DiyFp operator*(const DiyFp &rhs) const
static const uint64_t kDpExponentMask
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
DiyFp NormalizeBoundary() const
static const int kDpMinExponent
DiyFp operator-(const DiyFp &rhs) const
void NormalizedBoundaries(DiyFp *minus, DiyFp *plus) const
DiyFp GetCachedPower(int e, int *K)
DiyFp GetCachedPowerByIndex(size_t index)
static const uint64_t kDpHiddenBit
static const int kDpSignificandSize