diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 71f0840b..59a65c13 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -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(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('0' + digit); --exp; uint64_t remainder = (static_cast(hi) << -one.e) + lo; - if (remainder <= delta || size > max_digits) { + if (remainder <= delta || size > static_cast(max_digits)) { return grisu2_round( buf, size, max_digits, delta, remainder, static_cast(data::POWERS_OF_10_32[exp]) << -one.e, @@ -523,7 +523,7 @@ FMT_FUNC bool grisu2_gen_digits( buf[size++] = static_cast('0' + digit); lo &= one.f - 1; --exp; - if (lo < delta || size > max_digits) { + if (lo < delta || size > static_cast(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::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();