19 #ifndef RAPIDJSON_DIYFP_H_
20 #define RAPIDJSON_DIYFP_H_
22 #include "../rapidjson.h"
26 #if defined(_MSC_VER) && defined(_M_AMD64) && !defined(__INTEL_COMPILER)
28 #if !defined(_ARM64EC_)
29 #pragma intrinsic(_umul128)
31 #pragma comment(lib,"softintrin")
40 RAPIDJSON_DIAG_OFF(effc++)
45 RAPIDJSON_DIAG_OFF(padded)
76 #if defined(_MSC_VER) && defined(_M_AMD64)
81 return DiyFp(h,
e + rhs.
e + 64);
82 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
83 __extension__
typedef unsigned __int128 uint128;
84 uint128 p =
static_cast<uint128
>(
f) *
static_cast<uint128
>(rhs.
f);
89 return DiyFp(h,
e + rhs.
e + 64);
100 uint64_t tmp = (bd >> 32) + (ad & M32) + (bc & M32);
102 return DiyFp(ac + (ad >> 32) + (bc >> 32) + (tmp >> 32),
e + rhs.
e + 64);
107 int s =
static_cast<int>(
clzll(
f));
123 DiyFp pl =
DiyFp((
f << 1) + 1,
e - 1).NormalizeBoundary();
125 mi.
f <<= mi.
e - pl.
e;
143 return std::numeric_limits<double>::infinity();
167 static const uint64_t kCachedPowers_F[] = {
213 static const int16_t kCachedPowers_E[] = {
214 -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980,
215 -954, -927, -901, -874, -847, -821, -794, -768, -741, -715,
216 -688, -661, -635, -608, -582, -555, -529, -502, -475, -449,
217 -422, -396, -369, -343, -316, -289, -263, -236, -210, -183,
218 -157, -130, -103, -77, -50, -24, 3, 30, 56, 83,
219 109, 136, 162, 189, 216, 242, 269, 295, 322, 348,
220 375, 402, 428, 455, 481, 508, 534, 561, 588, 614,
221 641, 667, 694, 720, 747, 774, 800, 827, 853, 880,
222 907, 933, 960, 986, 1013, 1039, 1066
225 return DiyFp(kCachedPowers_F[index], kCachedPowers_E[index]);
231 double dk = (-61 - e) * 0.30102999566398114 + 347;
232 int k =
static_cast<int>(dk);
236 unsigned index =
static_cast<unsigned>((k >> 3) + 1);
237 *K = -(-348 +
static_cast<int>(index << 3));
244 unsigned index =
static_cast<unsigned>(
exp + 348) / 8u;
245 *outExp = -348 +
static_cast<int>(index) * 8;
255 RAPIDJSON_DIAG_OFF(padded)
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:437
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
__host__ T exp(T x)
Definition: math_v2.hpp:391
__host__ __device__ minus() -> minus< void, void >
FIXME: create macro to replace 'host device' and nothing more.
__host__ __device__ plus() -> plus< void, void >
FIXME: create macro to replace 'host device' and nothing more.
Definition: allocators.h:423
DiyFp GetCachedPowerByIndex(size_t index)
Definition: diyfp.h:165
DiyFp GetCachedPower10(int exp, int *outExp)
Definition: diyfp.h:242
DiyFp GetCachedPower(int e, int *K)
Definition: diyfp.h:228
uint32_t clzll(uint64_t x)
Definition: clzll.h:32
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1249
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:320
signed short int16_t
Definition: stdint.h:122
unsigned __int64 uint64_t
Definition: stdint.h:136
static const int kDpSignificandSize
Definition: diyfp.h:152
uint64_t f
Definition: diyfp.h:161
static const int kDpExponentBias
Definition: diyfp.h:153
DiyFp NormalizeBoundary() const
Definition: diyfp.h:111
static const uint64_t kDpHiddenBit
Definition: diyfp.h:159
static const int kDpMaxExponent
Definition: diyfp.h:154
static const uint64_t kDpSignificandMask
Definition: diyfp.h:158
DiyFp operator*(const DiyFp &rhs) const
Definition: diyfp.h:75
static const int kDpDenormalExponent
Definition: diyfp.h:156
DiyFp(uint64_t fp, int exp)
Definition: diyfp.h:51
static const int kDpMinExponent
Definition: diyfp.h:155
DiyFp operator-(const DiyFp &rhs) const
Definition: diyfp.h:71
DiyFp Normalize() const
Definition: diyfp.h:106
static const uint64_t kDpExponentMask
Definition: diyfp.h:157
static const int kDiySignificandSize
Definition: diyfp.h:151
double ToDouble() const
Definition: diyfp.h:131
DiyFp(double d)
Definition: diyfp.h:53
void NormalizedBoundaries(DiyFp *minus, DiyFp *plus) const
Definition: diyfp.h:122
DiyFp()
Definition: diyfp.h:49
int e
Definition: diyfp.h:162