-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Consider outputting a .0
suffix for FP values without a fractional part
#1075
Comments
I am strongly in favor of this. |
I’m in favour of adding |
I propose modifying both |
|
I go into a lot more detail in #1074, but I don't think this is a very solid rationale. FP numbers are not generally readable to non-technical users (e.g. FWIW, Racket appears to have something similar to our
Nevertheless, its |
In favour. |
This happened for Can this be closed, or are people still wanting this for |
Regardless of the outcome of issue #1074, we should consider suffixing
.0
for FP strings with no fractional part. A bare numeric literal with no exponent or decimal is typically an integer literal, not a float literal. This presents issues in various ways:-0
looks strange to programmers. Only the floating-point zero can be negative.-0
is much less likely to round-trip than-0.0
.2
, there may be unexpected truncation.Debug
's recent RFC 640 indicates that, "when it is feasible to do so, debugging output should match Rust syntax." While, say,4.0
is a valid FP value in Rust,4
is not.The
.0
suffix is reasonably widespread, though not as ubiquitous as minus zero. Exceptions include C# and Go. OCaml prints a bare.
suffix, as in42.
.Our JSON serializer suffixes
.0
to the result ofDisplay
. I feel that this should be the default behavior.It might also make sense to add the
.0
suffix even for floats with an exponent, though the need is less clear. It is somewhat more consistent, and it matches Haskell, Java, and Ruby. Thus far, I know that Erlang's REPL does not accept1e30
but does accept1.0e30
. I expect most systems to treat1e30
and1.0e30
equivalently.The text was updated successfully, but these errors were encountered: