-
Notifications
You must be signed in to change notification settings - Fork 87
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
Show -0.0 sign #236
Show -0.0 sign #236
Conversation
Ah, I’m more conflicted about this after looking at the diff and realising that JS’s .toString doesn’t include the minus sign for negative zero. I can definitely see this causing breakage at runtime without warning. I’ll see if I can find anything about this in IEEE 754. |
It turns out IEEE 754 doesn't say anything about functions like |
If we don’t infringe IEEE 754 by showing positive and negative zeroes differently is there any reason not to do it? |
I think the reasons not to do it are that a) people may be relying on the current behaviour, and b) there might be a good reason why JS's |
rust-lang/rust#20596 and rust-lang/rfcs#1074 are relevant |
This comment in runt-lang/rfcs#1074 shows how most popular languages handle this. One could get around this problem by specifying a newtype that will always include the sign, but that seems like overkill. |
I suspect that Number.prototype.toString hides the sign of negative zero to not leak its existence to end users? You’re right that people are probably using Show to display numbers in user interfaces (I certainly did it myself 😬). Perhaps we should rather make your Debug class the default in the REPL, show the sign of negative zero there and even deprecate Show if we’re feeling bold. |
I would love to deprecate Show in favour of Debug eventually, yes. |
Let’s close this for now and reconsider when replacing Show with Debug then? |
Works for me. |
Close #152.