Skip to content

Commit

Permalink
Merge pull request #329 from nightmouse/master
Browse files Browse the repository at this point in the history
Warning cleanup
  • Loading branch information
miloyip committed May 6, 2015
1 parent 85564d4 commit 1034587
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions include/rapidjson/internal/biginteger.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class BigInteger {
if (u == 1) return *this;
if (*this == 1) return *this = u;

uint32_t k = 0;
uint64_t k = 0;
for (size_t i = 0; i < count_; i++) {
const uint64_t c = digits_[i] >> 32;
const uint64_t d = digits_[i] & 0xFFFFFFFF;
Expand Down Expand Up @@ -246,7 +246,7 @@ class BigInteger {
__extension__ typedef unsigned __int128 uint128;
uint128 p = static_cast<uint128>(a) * static_cast<uint128>(b);
p += k;
*outHigh = p >> 64;
*outHigh = static_cast<uint64_t>(p >> 64);
return static_cast<uint64_t>(p);
#else
const uint64_t a0 = a & 0xFFFFFFFF, a1 = a >> 32, b0 = b & 0xFFFFFFFF, b1 = b >> 32;
Expand Down
4 changes: 2 additions & 2 deletions include/rapidjson/internal/diyfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct DiyFp {
uint64_t u64;
} u = { d };

int biased_e = (u.u64 & kDpExponentMask) >> kDpSignificandSize;
int biased_e = static_cast<int>((u.u64 & kDpExponentMask) >> kDpSignificandSize);
uint64_t significand = (u.u64 & kDpSignificandMask);
if (biased_e != 0) {
f = significand + kDpHiddenBit;
Expand All @@ -71,7 +71,7 @@ struct DiyFp {
#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
__extension__ typedef unsigned __int128 uint128;
uint128 p = static_cast<uint128>(f) * static_cast<uint128>(rhs.f);
uint64_t h = p >> 64;
uint64_t h = static_cast<uint64_t>(p >> 64);
uint64_t l = static_cast<uint64_t>(p);
if (l & (uint64_t(1) << 63)) // rounding
h++;
Expand Down
30 changes: 15 additions & 15 deletions include/rapidjson/internal/ieee754.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ namespace internal {
class Double {
public:
Double() {}
Double(double d) : d(d) {}
Double(uint64_t u) : u(u) {}
Double(double d) : d_(d) {}
Double(uint64_t u) : u_(u) {}

double Value() const { return d; }
uint64_t Uint64Value() const { return u; }
double Value() const { return d_; }
uint64_t Uint64Value() const { return u_; }

double NextPositiveDouble() const {
RAPIDJSON_ASSERT(!Sign());
return Double(u + 1).Value();
return Double(u_ + 1).Value();
}

bool Sign() const { return (u & kSignMask) != 0; }
uint64_t Significand() const { return u & kSignificandMask; }
int Exponent() const { return ((u & kExponentMask) >> kSignificandSize) - kExponentBias; }
bool Sign() const { return (u_ & kSignMask) != 0; }
uint64_t Significand() const { return u_ & kSignificandMask; }
int Exponent() const { return static_cast<int>(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); }

bool IsNan() const { return (u & kExponentMask) == kExponentMask && Significand() != 0; }
bool IsInf() const { return (u & kExponentMask) == kExponentMask && Significand() == 0; }
bool IsNormal() const { return (u & kExponentMask) != 0 || Significand() == 0; }
bool IsZero() const { return (u & (kExponentMask | kSignificandMask)) == 0; }
bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; }
bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; }
bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; }
bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; }

uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); }
int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; }
uint64_t ToBias() const { return (u & kSignMask) ? ~u + 1 : u | kSignMask; }
uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; }

static unsigned EffectiveSignificandSize(int order) {
if (order >= -1021)
Expand All @@ -66,8 +66,8 @@ class Double {
static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000);

union {
double d;
uint64_t u;
double d_;
uint64_t u_;
};
};

Expand Down

0 comments on commit 1034587

Please sign in to comment.