mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Fix sign-conversion warnings reported by Clang7
This commit is contained in:
parent
ea5e4790bd
commit
77656c672c
@ -464,14 +464,14 @@ FMT_FUNC fp get_cached_power(int min_exponent, int &pow10_exponent) {
|
||||
}
|
||||
|
||||
FMT_FUNC bool grisu2_round(
|
||||
char *buf, size_t &size, size_t max_digits, uint64_t delta,
|
||||
char *buf, ptrdiff_t &size, size_t max_digits, uint64_t delta,
|
||||
uint64_t remainder, uint64_t exp, uint64_t diff, int &exp10) {
|
||||
while (remainder < diff && delta - remainder >= exp &&
|
||||
(remainder + exp < diff || diff - remainder > remainder + exp - diff)) {
|
||||
--buf[size - 1];
|
||||
remainder += exp;
|
||||
}
|
||||
if (size > max_digits) {
|
||||
if (size > static_cast<ptrdiff_t>(max_digits)) {
|
||||
--size;
|
||||
++exp10;
|
||||
if (buf[size] >= '5')
|
||||
@ -482,7 +482,7 @@ FMT_FUNC bool grisu2_round(
|
||||
|
||||
// Generates output using Grisu2 digit-gen algorithm.
|
||||
FMT_FUNC bool grisu2_gen_digits(
|
||||
char *buf, size_t &size, uint32_t hi, uint64_t lo, int &exp,
|
||||
char *buf, ptrdiff_t &size, uint32_t hi, uint64_t lo, int &exp,
|
||||
uint64_t delta, const fp &one, const fp &diff, size_t max_digits) {
|
||||
// Generate digits for the most significant part (hi).
|
||||
while (exp > 0) {
|
||||
@ -507,7 +507,7 @@ FMT_FUNC bool grisu2_gen_digits(
|
||||
buf[size++] = static_cast<char>('0' + digit);
|
||||
--exp;
|
||||
uint64_t remainder = (static_cast<uint64_t>(hi) << -one.e) + lo;
|
||||
if (remainder <= delta || size > max_digits) {
|
||||
if (remainder <= delta || size > static_cast<ptrdiff_t>(max_digits)) {
|
||||
return grisu2_round(
|
||||
buf, size, max_digits, delta, remainder,
|
||||
static_cast<uint64_t>(data::POWERS_OF_10_32[exp]) << -one.e,
|
||||
@ -523,7 +523,7 @@ FMT_FUNC bool grisu2_gen_digits(
|
||||
buf[size++] = static_cast<char>('0' + digit);
|
||||
lo &= one.f - 1;
|
||||
--exp;
|
||||
if (lo < delta || size > max_digits) {
|
||||
if (lo < delta || size > static_cast<ptrdiff_t>(max_digits)) {
|
||||
return grisu2_round(buf, size, max_digits, delta, lo, one.f,
|
||||
diff.f * data::POWERS_OF_10_32[-exp], exp);
|
||||
}
|
||||
@ -751,7 +751,7 @@ FMT_FUNC typename std::enable_if<sizeof(Double) == sizeof(uint64_t), bool>::type
|
||||
// lo (p2 in Grisu) contains the least significants digits of scaled_upper.
|
||||
// lo = supper % one.
|
||||
uint64_t lo = upper.f & (one.f - 1);
|
||||
size_t size = 0;
|
||||
ptrdiff_t size = 0;
|
||||
if (!grisu2_gen_digits(buf.data(), size, hi, lo, exp, delta, one, diff,
|
||||
params.num_digits)) {
|
||||
buf.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user