Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rounding cases for fixed-width printing in ryu routines
Fixes JuliaLang#40303. When printing values to fixed widths through the `Ryu.writefixed` or `Ryu.writeexp` routines, we have a "cleanup" section after a value has been printed to see if it needs to be rounded given the input precision and width. The core issue was the terminating condition: it previously only checked if we were at the start of a buffer or had encountered the `'-'` character. Via Printf formatting, however, it also allows specifying the `'+'` and `' '` characters to preceed a formatted number. Hence, in the OP, the `'1'` character was getting "rounded" up to the `','` character. The fix here is correctly checking if the `plus` or `space` options were passed to the routine and if so, include those in our rounding termination check. The original issue only reported the "plus" case for the `f` format specifier, but the same bug affects the `e` format specifier and the "space" option.
- Loading branch information