(
doublesignificand,
intexp) {
46 template<
typenameT>
58 const inthExp = bExp - 1;
60 intdS_Exp2 = 0, dS_Exp5 = 0, bS_Exp2 = 0, bS_Exp5 = 0, hS_Exp2 = 0, hS_Exp5 = 0;
91 intcommon_Exp2 =
Min3(dS_Exp2, bS_Exp2, hS_Exp2);
92dS_Exp2 -= common_Exp2;
93bS_Exp2 -= common_Exp2;
94hS_Exp2 -= common_Exp2;
97dS.
MultiplyPow5(
static_cast<unsigned>(dS_Exp5)) <<=
static_cast<unsigned>(dS_Exp2);
100bS.
MultiplyPow5(
static_cast<unsigned>(bS_Exp5)) <<=
static_cast<unsigned>(bS_Exp2);
103hS.
MultiplyPow5(
static_cast<unsigned>(hS_Exp5)) <<=
static_cast<unsigned>(hS_Exp2);
108 return delta.Compare(hS);
114 if(p > 22 && p < 22 + 16) {
120 if(p >= -22 && p <= 22 && d <= 9007199254740991.0) {
129 inline bool StrtodDiyFp(
const char* decimals,
size_tlength,
size_tdecimalPosition,
intexp,
double*
result) {
132 for(;
i< length;
i++) {
136significand = significand * 10u +
static_cast<unsigned>(decimals[
i] -
'0');
139 if(
i< length && decimals[
i] >=
'5')
142 size_tremaining = length -
i;
143 const intkUlpShift = 3;
144 const intkUlp = 1 << kUlpShift;
147 DiyFpv(significand, 0);
151 const intdExp =
static_cast<int>(decimalPosition) -
static_cast<int>(
i) + exp;
155 if(actualExp != dExp) {
156 static const DiyFpkPow10[] = {
165 intadjustment = dExp - actualExp - 1;
167v = v * kPow10[adjustment];
168 if(length +
static_cast<unsigned>(adjustment)> 19u)
176 const intoldExp = v.
e;
180 const inteffectiveSignificandSize = Double::EffectiveSignificandSize(64 + v.
e);
181 intprecisionSize = 64 - effectiveSignificandSize;
182 if(precisionSize + kUlpShift >= 64) {
183 intscaleExp = (precisionSize + kUlpShift) - 63;
187precisionSize -= scaleExp;
190 DiyFprounded(v.
f>> precisionSize, v.
e+ precisionSize);
191 const uint64_tprecisionBits = (v.
f& ((
uint64_t(1) << precisionSize) - 1)) * kUlp;
193 if(precisionBits >= halfWay +
static_cast<unsigned>(
error)) {
195 if(rounded.
f& (DiyFp::kDpHiddenBit << 1)) {
203 returnhalfWay -
static_cast<unsigned>(
error) >= precisionBits || precisionBits >= halfWay +
static_cast<unsigned>(
error);
206 inline double StrtodBigInteger(
double approx,
const char* decimals,
size_tlength,
size_tdecimalPosition,
intexp) {
208 const intdExp =
static_cast<int>(decimalPosition) -
static_cast<int>(length) + exp;
213 else if(
cmp== 0) {
215 if(
a.Significand() & 1)
216 return a.NextPositiveDouble();
221 return a.NextPositiveDouble();
224 inline double StrtodFullPrecision(
doubled,
intp,
const char* decimals,
size_tlength,
size_tdecimalPosition,
intexp) {
233 while(*decimals ==
'0'&& length > 1) {
240 while(decimals[length - 1] ==
'0'&& length > 1) {
247 const intkMaxDecimalDigit = 780;
248 if(
static_cast<int>(length) > kMaxDecimalDigit) {
249 int delta= (
static_cast<int>(length) - kMaxDecimalDigit);
251decimalPosition -=
static_cast<unsigned>(
delta);
252length = kMaxDecimalDigit;
256 if(
int(length) + exp < -324)
bool Difference(const BigInteger &rhs, BigInteger *out) const
BigInteger & MultiplyPow5(unsigned exp)
int IntegerExponent() const
uint64_t IntegerSignificand() const
#define RAPIDJSON_ASSERT(x)
Assertion.
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
double StrtodNormalPrecision(double d, int p)
int CheckWithinHalfULP(double b, const BigInteger &d, int dExp)
DiyFp GetCachedPower10(int exp, int *outExp)
double StrtodBigInteger(double approx, const char *decimals, size_t length, size_t decimalPosition, int exp)
bool StrtodDiyFp(const char *decimals, size_t length, size_t decimalPosition, int exp, double *result)
double FastPath(double significand, int exp)
double Pow10(int n)
Computes integer powers of 10 in double (10.0^n).
bool StrtodFast(double d, int p, double *result)
double StrtodFullPrecision(double d, int p, const char *decimals, size_t length, size_t decimalPosition, int exp)
bool approx(T x_, T y_, T eps_)
Int4 delta(size_t dimension_, const Int4 *score_)
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4