15 #ifndef RAPIDJSON_STRTOD_ 16 #define RAPIDJSON_STRTOD_ 58 const int hExp = bExp - 1;
60 int dS_Exp2 = 0, dS_Exp5 = 0, bS_Exp2 = 0, bS_Exp5 = 0, hS_Exp2 = 0, hS_Exp5 = 0;
91 int common_Exp2 =
Min3(dS_Exp2, bS_Exp2, hS_Exp2);
92 dS_Exp2 -= common_Exp2;
93 bS_Exp2 -= common_Exp2;
94 hS_Exp2 -= common_Exp2;
97 dS.
MultiplyPow5(static_cast<unsigned>(dS_Exp5)) <<=
static_cast<unsigned>(dS_Exp2);
100 bS.
MultiplyPow5(static_cast<unsigned>(bS_Exp5)) <<=
static_cast<unsigned>(bS_Exp2);
103 hS.
MultiplyPow5(static_cast<unsigned>(hS_Exp5)) <<=
static_cast<unsigned>(hS_Exp2);
114 if (
p > 22 &&
p < 22 + 16) {
120 if (
p >= -22 &&
p <= 22 && d <= 9007199254740991.0) {
136 significand = significand * 10u +
static_cast<unsigned>(decimals[i] -
'0');
139 if (i <
length && decimals[i] >=
'5')
142 size_t remaining =
length - i;
143 const unsigned kUlpShift = 3;
144 const unsigned kUlp = 1 << kUlpShift;
151 const int dExp =
static_cast<int>(decimalPosition) - static_cast<int>(i) +
exp;
155 if (actualExp != dExp) {
156 static const DiyFp kPow10[] = {
165 int adjustment = dExp - actualExp - 1;
167 v =
v * kPow10[adjustment];
168 if (
length + static_cast<unsigned>(adjustment)> 19u)
176 const int oldExp =
v.e;
181 unsigned precisionSize = 64 - effectiveSignificandSize;
182 if (precisionSize + kUlpShift >= 64) {
183 unsigned scaleExp = (precisionSize + kUlpShift) - 63;
186 error = (
error >> scaleExp) + 1 + static_cast<int>(kUlp);
187 precisionSize -= scaleExp;
190 DiyFp rounded(
v.f >> precisionSize,
v.e + static_cast<int>(precisionSize));
191 const uint64_t precisionBits = (
v.f & ((
uint64_t(1) << precisionSize) - 1)) * kUlp;
193 if (precisionBits >= halfWay + static_cast<unsigned>(
error)) {
203 return halfWay -
static_cast<unsigned>(
error) >= precisionBits || precisionBits >= halfWay + static_cast<unsigned>(
error);
208 const int dExp =
static_cast<int>(decimalPosition) - static_cast<int>(
length) +
exp;
215 if (
a.Significand() & 1)
216 return a.NextPositiveDouble();
221 return a.NextPositiveDouble();
233 while (*decimals ==
'0' &&
length > 1) {
247 const int kMaxDecimalDigit = 780;
248 if (static_cast<int>(
length) > kMaxDecimalDigit) {
249 int delta = (
static_cast<int>(
length) - kMaxDecimalDigit);
251 decimalPosition -=
static_cast<unsigned>(delta);
252 length = kMaxDecimalDigit;
269 #endif // RAPIDJSON_STRTOD_ uint64_t f
Definition: diyfp.h:160
double StrtodFullPrecision(double d, int p, const char *decimals, size_t length, size_t decimalPosition, int exp)
Definition: strtod.h:224
double FastPath(double significand, int exp)
Definition: strtod.h:26
static unsigned EffectiveSignificandSize(int order)
Definition: ieee754.h:51
uint64_t IntegerSignificand() const
Definition: ieee754.h:47
double Pow10(int n)
Computes integer powers of 10 in double (10.0^n).
Definition: pow10.h:28
Definition: biginteger.h:28
bool Difference(const BigInteger &rhs, BigInteger *out) const
Definition: biginteger.h:186
int e
Definition: diyfp.h:161
bool StrtodDiyFp(const char *decimals, size_t length, size_t decimalPosition, int exp, double *result)
Definition: strtod.h:129
#define exp(a)
Definition: math.h:32
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:119
const GLubyte * c
Definition: glext.h:9812
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
int IntegerExponent() const
Definition: ieee754.h:48
DiyFp GetCachedPower10(int exp, int *outExp)
Definition: diyfp.h:240
double StrtodNormalPrecision(double d, int p)
Definition: strtod.h:35
double StrtodBigInteger(double approx, const char *decimals, size_t length, size_t decimalPosition, int exp)
Definition: strtod.h:206
static l_noret error(LoadState *S, const char *why)
Definition: lundump.c:39
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:402
GLuint64EXT * result
Definition: glext.h:12211
Definition: document.h:391
static const uint64_t kDpHiddenBit
Definition: diyfp.h:158
GLfloat GLfloat p
Definition: glext.h:9809
BigInteger & MultiplyPow5(unsigned exp)
Definition: biginteger.h:162
const GLdouble * v
Definition: glext.h:6391
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:116
signed __int64 int64_t
Definition: stdint.h:135
bool StrtodFast(double d, int p, double *result)
Definition: strtod.h:111
int CheckWithinHalfULP(double b, const BigInteger &d, int dExp)
Definition: strtod.h:54
int Compare(const BigInteger &rhs) const
Definition: biginteger.h:208
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:289
unsigned __int64 uint64_t
Definition: stdint.h:136
GLenum GLuint GLenum GLsizei length
Definition: glext.h:6233
const GLfloat * m
Definition: glext.h:11755
double ToDouble() const
Definition: diyfp.h:139
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844
T Min3(T a, T b, T c)
Definition: strtod.h:47