mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-03-10 03:29:59 +01:00
Remove more unused code paths in double conversions
This commit is contained in:
parent
402d75a801
commit
2689cc4974
@ -172,13 +172,10 @@ public:
|
||||
}
|
||||
|
||||
// Compute absolute difference of this and rhs.
|
||||
// Return false if this < rhs
|
||||
// Assume this != rhs
|
||||
bool Difference(const BigInteger& rhs, BigInteger* out) const {
|
||||
int cmp = Compare(rhs);
|
||||
if (cmp == 0) {
|
||||
*out = BigInteger(0);
|
||||
return false;
|
||||
}
|
||||
RAPIDJSON_ASSERT(cmp != 0);
|
||||
const BigInteger *a, *b; // Makes a > b
|
||||
bool ret;
|
||||
if (cmp < 0) { a = &rhs; b = this; ret = true; }
|
||||
|
@ -104,19 +104,9 @@ inline int CheckWithinHalfULP(double b, const BigInteger& d, int dExp) {
|
||||
hS.MultiplyPow5(hS_Exp5) <<= hS_Exp2;
|
||||
|
||||
BigInteger delta(0);
|
||||
bool adjustToNegative = dS.Difference(bS, &delta);
|
||||
dS.Difference(bS, &delta);
|
||||
|
||||
int cmp = delta.Compare(hS);
|
||||
// If delta is within 1/2 ULP, check for special case when significand is power of two.
|
||||
// In this case, need to compare with 1/2h in the lower bound.
|
||||
if (cmp < 0 && adjustToNegative && // within and dS < bS
|
||||
db.IsNormal() && (bInt & (bInt - 1)) == 0 && // Power of 2
|
||||
db.Uint64Value() != RAPIDJSON_UINT64_C2(0x00100000, 0x00000000)) // minimum normal number must not do this
|
||||
{
|
||||
delta <<= 1;
|
||||
return delta.Compare(hS);
|
||||
}
|
||||
return cmp;
|
||||
return delta.Compare(hS);
|
||||
}
|
||||
|
||||
inline bool StrtodFast(double d, int p, double* result) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user