Convert negative precision to zero in printf (#1127)

and remove redundant check in grisu2_prettify.
This commit is contained in:
Victor Zverovich
2019-04-21 07:44:04 -07:00
parent 5efb24dd2b
commit bd516e3429
3 changed files with 7 additions and 4 deletions
+1 -2
View File
@@ -1181,8 +1181,7 @@ It grisu2_prettify(const char* digits, int size, int exp, It it,
*it++ = static_cast<Char>(params.upper ? 'E' : 'e');
return write_exponent<Char>(exp, it);
}
const int exp_threshold = 21;
if (size <= full_exp && full_exp <= exp_threshold) {
if (size <= full_exp) {
// 1234e7 -> 12340000000[.0+]
it = copy_str<Char>(digits, digits + size, it);
it = std::fill_n(it, full_exp - size, static_cast<Char>('0'));