diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 59a65c13..9b739635 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -539,7 +539,7 @@ FMT_FUNC bool grisu2_gen_digits( #endif struct gen_digits_params { - unsigned num_digits; + int num_digits; bool fixed; bool upper; bool trailing_zeros; @@ -617,11 +617,11 @@ struct fill { // The number is given as v = f * pow(10, exp), where f has size digits. template FMT_FUNC void grisu2_prettify(const gen_digits_params ¶ms, - ptrdiff_t size, int exp, Handler &&handler) { + int size, int exp, Handler &&handler) { if (!params.fixed) { // Insert a decimal point after the first digit and add an exponent. handler.insert(1, '.'); - exp += static_cast(size) - 1; + exp += size - 1; if (size < params.num_digits) handler.append(params.num_digits - size, '0'); handler.append(params.upper ? 'E' : 'e'); @@ -629,13 +629,12 @@ FMT_FUNC void grisu2_prettify(const gen_digits_params ¶ms, return; } // pow(10, full_exp - 1) <= v <= pow(10, full_exp). - int int_size = static_cast(size); - int full_exp = int_size + exp; + int full_exp = size + exp; const int exp_threshold = 21; - if (int_size <= full_exp && full_exp <= exp_threshold) { + if (size <= full_exp && full_exp <= exp_threshold) { // 1234e7 -> 12340000000[.0+] - handler.append(full_exp - int_size, '0'); - int num_zeros = static_cast(params.num_digits) - full_exp; + handler.append(full_exp - size, '0'); + int num_zeros = params.num_digits - full_exp; if (num_zeros > 0 && params.trailing_zeros) { handler.append('.'); handler.append(num_zeros, '0');