[GHC] #9810: encodeFloat 1 2047 = -1024.0

#9810: encodeFloat 1 2047 = -1024.0 -------------------------------------+------------------------------------- Reporter: luite | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- When the following code is compiled with optimization, it prints `-1024.0`, without optimization the result is `Infinity`. {{{#!hs main = print ((encodeFloat 1 2047) :: Double) }}} I think this might be caused by changes in decoding doubles in `integer- gmp2`. While `decodeFloat` is lossy, since we can not represent exceptional values, `encodeFloat` should never give a different answer here. Also `cgrun044` now gives a different result when compiled with optimization. It was broken anyway, since it claims some values are `NaN`, while actually `Infinity` is printed (also with 7.8), but it used to give the same answer regardless of optimization with GHC 7.8 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9810 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9810: encodeFloat 1 2047 = -1024.0 -------------------------------------+------------------------------------- Reporter: luite | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: #9811 Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by rwbarton): * related: => #9811 Comment: The old correct behavior depended somewhat precariously on being able to round-trip floating-point infinities through `toRational/fromRational`. This causes other wrong behavior, see #9811. While the situation with constant folding of floating-point is not ideal anyways, we should restore the old behavior of `toRational` (`decodeFloat`). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9810#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9810: encodeFloat 1 2047 = -1024.0 -------------------------------------+------------------------------------- Reporter: luite | Owner: hvr Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 Resolution: | Keywords: ieee Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: #9811 Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by hvr): * cc: ekmett (added) * keywords: => ieee * owner: => hvr * milestone: => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9810#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9810: encodeFloat 1 2047 = -1024.0 -------------------------------------+------------------------------------- Reporter: luite | Owner: hvr Type: bug | Status: patch Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 Resolution: | Keywords: ieee Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: #9811 Test Case: | Blocking: | Differential Revisions: Phab:D486 | -------------------------------------+------------------------------------- Changes (by hvr): * status: new => patch * differential: => Phab:D486 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9810#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9810: encodeFloat 1 2047 = -1024.0
-------------------------------------+-------------------------------------
Reporter: luite | Owner: hvr
Type: bug | Status: patch
Priority: normal | Milestone: 7.10.1
Component: Compiler | Version: 7.9
Resolution: | Keywords: ieee
Operating System: | Architecture: Unknown/Multiple
Unknown/Multiple | Difficulty: Unknown
Type of failure: | Blocked By:
None/Unknown | Related Tickets: #9811
Test Case: |
Blocking: |
Differential Revisions: Phab:D486 |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel
decodeFloat (-1/0) (-4503599627370496,972)
decodeFloat (1/0) (4503599627370496,972)
decodeFloat (0/0) (-6755399441055744,972)
Currently (broken) semantics:
decodeFloat (-1/0 :: Double) (-9223372036854775808,-53)
decodeFloat (1/0 :: Double) (-9223372036854775808,-53)
decodeFloat (0/0 :: Double) (-9223372036854775808,-53)
This patch reverts to the old expected semantics. I plan to revisit the implementation during GHC 7.11 development. This should address #9810 Reviewed By: austin, ekmett, luite Differential Revision: https://phabricator.haskell.org/D486 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9810#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9810: encodeFloat 1 2047 = -1024.0 -------------------------------------+------------------------------------- Reporter: luite | Owner: hvr Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 Resolution: fixed | Keywords: ieee Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: #9811 Test Case: | Blocking: | Differential Revisions: Phab:D486 | -------------------------------------+------------------------------------- Changes (by hvr): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9810#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC