-
-
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
Should zero(::Float) = -0.0? #18341
Comments
I tried this change out to see what would break, and... apparently quite a lot. For some reason, this change is not as trivial as I expected. Tests that failed include hashing and sorting. I'll investigate why the breakages happened. |
After further experimentation, I'm convinced that this change will make things worse, not better. |
"Worse" in the sense that On the other hand, Julia's implementation of |
Unrelated fallout. I was hoping that the test failures were trivially fixed (such as by changing The problem that I have had little success trying to address is that there is some code that makes the assumption that |
IEEE defines
-0.0 + 0.0 === 0.0 + (-0.0) === 0.0
, which means that the additive identity ofFloatnn
is actually-0.0
, not0.0
. This is significant whenzero(x)
is used as the base of reductions, such as in the below definition:Another example of this issue is #18336. Is setting
zero(Float64)
and co. to negative zero a sensible idea? As far as I can tell, the signed zeroes behave very similarly in most contexts, so I suspect there won't be much downside.The text was updated successfully, but these errors were encountered: