-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
10 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -704,7 +704,12 @@ FMT_INLINE FMT_CONSTEXPR20 digits::result grisu_gen_digits( | |
if (handler.fixed) { | ||
// Adjust fixed precision by exponent because it is relative to decimal | ||
// point. | ||
handler.precision += exp + handler.exp10; | ||
int precision_offset = exp + handler.exp10; | ||
if (precision_offset > 0 && | ||
handler.precision > max_value<int>() - precision_offset) { | ||
throw format_error("number is too big"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bsongis-frsky
|
||
} | ||
handler.precision += precision_offset; | ||
// Check if precision is satisfied just by leading zeros, e.g. | ||
// format("{:.2f}", 0.001) gives "0.00" without generating any digits. | ||
if (handler.precision <= 0) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Is it possible to use FMT_THROW here without breaking everything?