-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floats print with incorrect rounding in compact context #36234
Comments
This appears to be an edge case for floats with exactly 6 digits before the decimal place: julia> sprint(show, 12.345678, context=:compact=>true)
"12.3457"
julia> sprint(show, 123.45678, context=:compact=>true)
"123.457"
julia> sprint(show, 1234.5678, context=:compact=>true)
"1234.57"
julia> sprint(show, 12345.678, context=:compact=>true)
"12345.7"
julia> sprint(show, 123456.78, context=:compact=>true) # Incorrect
"123457.0"
julia> sprint(show, 1234567.8, context=:compact=>true)
"1.23457e6"
|
I guess I see what's happening here: the value is correctly rounded to |
Ah, I guess it should be printed as |
Or perhaps the compact display logic should avoid rounding to 0 digits? It doesn't save any space to do so, since the .0 will be appended anyway. |
Bump @quinnj --- I doubt there is time for this in 1.5 but this seems pretty bad. |
rather than the current incorrect
why not re-adopt what @vtjnash had done
|
to obtain
fix Line 333 of Ryu/shortest.jl
by replacing
|
Well, it appears there are other impinging considerations. So I closed the PR. Someone more familiar with the other uses of that line ... |
Fix is up: #36819 |
Fixed via #36819 |
Similar to #33185 but present in 1.4.2 and 1.5-beta1.
Originally from: https://discourse.julialang.org/t/incorrect-display-of-array-float64-2-numbers/41200/3
MWE:
The
.0
is wrong--it ought to be.3
.The text was updated successfully, but these errors were encountered: