-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
"{:?}" for 0. is 0
instead of 0.
#30967
Comments
There's no way to distinguish between IIRC The current float pretty printer just uses as many decimal places needed to prevent rounding errors from reading it back. However, I don't think it's a bad idea to always print floats unambiguously (ie. always print a decimal point, even when not needed for accuracy). |
Yes, I would like it to always print |
This was discussed before, and IIRC rejected because of backwards compatibility concerns. Or maybe I'm mistaken and it was only using exponential notation by default that was rejected. See #24612 for some context, I'm sure there's more. |
Also, do I understand correctly that your use case would require all floats that can be printed as integers to include a trailing |
just use |
I'll go out on a limb and say that This issue does of course relate to all whole number floating point values, not just zero. |
/cc @rust-lang/libs |
I agree that the Marking feature-accepted as I would be prepared to consider a PR fixing this, but if the PR turns out to be controversial then we may ask for an RFC. |
Always `Debug` floats with a decimal point Fixes rust-lang#30967 r? @dtolnay
This code:
produces
0
, but I would expect0.
. This breaks the convention of Rust source code.https://play.rust-lang.org/?gist=e1f1c703b2c582ddc3c3&version=nightly
The text was updated successfully, but these errors were encountered: