15 #ifndef RAPIDJSON_IEEE754_
16 #define RAPIDJSON_IEEE754_
18 #include "../rapidjson.h"
26 Double(
double d) : d_(d) {}
27 Double(uint64_t u) : u_(u) {}
29 double Value()
const {
return d_; }
30 uint64_t Uint64Value()
const {
return u_; }
32 double NextPositiveDouble()
const {
34 return Double(u_ + 1).Value();
37 bool Sign()
const {
return (u_ & kSignMask) != 0; }
38 uint64_t Significand()
const {
return u_ & kSignificandMask; }
39 int Exponent()
const {
return static_cast<int>(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); }
41 bool IsNan()
const {
return (u_ & kExponentMask) == kExponentMask && Significand() != 0; }
42 bool IsInf()
const {
return (u_ & kExponentMask) == kExponentMask && Significand() == 0; }
43 bool IsNanOrInf()
const {
return (u_ & kExponentMask) == kExponentMask; }
44 bool IsNormal()
const {
return (u_ & kExponentMask) != 0 || Significand() == 0; }
45 bool IsZero()
const {
return (u_ & (kExponentMask | kSignificandMask)) == 0; }
47 uint64_t IntegerSignificand()
const {
return IsNormal() ? Significand() | kHiddenBit : Significand(); }
48 int IntegerExponent()
const {
return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; }
49 uint64_t ToBias()
const {
return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; }
51 static unsigned EffectiveSignificandSize(
int order) {
54 else if (order <= -1074)
57 return static_cast<unsigned>(order) + 1074;
61 static const int kSignificandSize = 52;
62 static const int kExponentBias = 0x3FF;
63 static const int kDenormalExponent = 1 - kExponentBias;
Represents a JSON value. Use Value for UTF8 encoding and default allocator.
Definition: document.h:540
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:402
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:289