Skip to content

Commit

Permalink
Merge pull request Tencent#150 from TyRoXx/conversion_warnings
Browse files Browse the repository at this point in the history
turn implicit integer conversions into static_casts to avoid warnings
  • Loading branch information
miloyip committed Sep 18, 2014
2 parents ca9b2d1 + b9608f2 commit 42de1ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions include/rapidjson/internal/dtoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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 @@ -78,7 +78,7 @@ struct DiyFp {
return DiyFp(h, e + rhs.e + 64);
#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)
unsigned __int128 p = static_cast<unsigned __int128>(f) * static_cast<unsigned __int128>(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 Expand Up @@ -284,7 +284,7 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff
#endif
}
if (d || *len)
buffer[(*len)++] = '0' + static_cast<char>(d);
buffer[(*len)++] = static_cast<char>('0' + static_cast<char>(d));
kappa--;
uint64_t tmp = (static_cast<uint64_t>(p1) << -one.e) + p2;
if (tmp <= delta) {
Expand All @@ -300,7 +300,7 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff
delta *= 10;
char d = static_cast<char>(p2 >> -one.e);
if (d || *len)
buffer[(*len)++] = '0' + d;
buffer[(*len)++] = static_cast<char>('0' + d);
p2 &= one.f - 1;
kappa--;
if (p2 < delta) {
Expand Down Expand Up @@ -332,7 +332,7 @@ inline char* WriteExponent(int K, char* buffer) {
}

if (K >= 100) {
*buffer++ = '0' + static_cast<char>(K / 100);
*buffer++ = static_cast<char>('0' + static_cast<char>(K / 100));
K %= 100;
const char* d = GetDigitsLut() + K * 2;
*buffer++ = d[0];
Expand All @@ -344,7 +344,7 @@ inline char* WriteExponent(int K, char* buffer) {
*buffer++ = d[1];
}
else
*buffer++ = '0' + static_cast<char>(K);
*buffer++ = static_cast<char>('0' + static_cast<char>(K));

return buffer;
}
Expand Down
6 changes: 3 additions & 3 deletions include/rapidjson/internal/itoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ inline char* u32toa(uint32_t value, char* buffer) {
*buffer++ = cDigitsLut[i + 1];
}
else
*buffer++ = '0' + static_cast<char>(a);
*buffer++ = static_cast<char>('0' + static_cast<char>(a));

const uint32_t b = value / 10000; // 0 to 9999
const uint32_t c = value % 10000; // 0 to 9999
Expand Down Expand Up @@ -227,14 +227,14 @@ inline char* u64toa(uint64_t value, char* buffer) {
value %= kTen16;

if (a < 10)
*buffer++ = '0' + static_cast<char>(a);
*buffer++ = static_cast<char>('0' + static_cast<char>(a));
else if (a < 100) {
const uint32_t i = a << 1;
*buffer++ = cDigitsLut[i];
*buffer++ = cDigitsLut[i + 1];
}
else if (a < 1000) {
*buffer++ = '0' + static_cast<char>(a / 100);
*buffer++ = static_cast<char>('0' + static_cast<char>(a / 100));

const uint32_t i = (a % 100) << 1;
*buffer++ = cDigitsLut[i];
Expand Down

0 comments on commit 42de1ce

Please sign in to comment.