NegativeLiterals -0.0 :: Double
Compare
rwbarton@morphism:~$ ghc-8.0.1 -e '-0.0'
-0.0
rwbarton@morphism:~$ ghc-8.0.1 -XNegativeLiterals -e '-0.0'
0.0
This behavior is logical, but unexpected. The logic is that with NegativeLiterals
the literal -0.0
means fromRational ((-0)%0)
, which equals fromRational 0
, which for Double
is positive zero, not negative zero.
But this seems unfortunate. Perhaps it would be best if -0.0
(or -
applied to any other literal mathematically equal to zero) was desugared as negate 0.0
even under NegativeLiterals
, since there doesn't seem to be any other reason to write -0.0
.
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |