julia
9d41eb34 - Ensure Ryu.writeexp doesn't round past starting position (#37546)

Commit
5 years ago
Ensure Ryu.writeexp doesn't round past starting position (#37546) Fixes #37539. The issue here was the `Ryu.writeexp` code got to the rounding section and started rounding `0.999` up to precision of 1, but because the format string specifies a space before the number, it kept rounding the space "digit", which messed up the final string. The solution proposed here keeps track of the original starting `pos` when we start `writeexp` and terminates the rounding sequence if we get there. I also checked `Ryu.writefixed`, because it has similar rounding code, but it doesn't fail on quite the same case because it explicitly keeps track of the decimal point and will terminate rounding based on that in some cases. I did, however, manage to reproduce with `9.999`, because the rounding then extends before the decimal point, so a similar fix is applied to `writefixed`.
Author
Parents
Loading