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 -1
View File
@@ -44,7 +44,7 @@ class printf_precision_handler : public function<int> {
int operator()(T value) {
if (!int_checker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
FMT_THROW(format_error("number is too big"));
return static_cast<int>(value);
return (std::max)(static_cast<int>(value), 0);
}
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>