#3676: realToFrac doesn't sanely convert between floating types ----------------------------------+----------------------------------------- Reporter: draconx | Owner: simonmar Type: bug | Status: assigned Priority: normal | Milestone: _|_ Component: libraries (other) | Version: 6.12.1 Keywords: | Difficulty: Os: Unknown/Multiple | Testcase: Architecture: x86_64 (amd64) | Failure: None/Unknown ----------------------------------+----------------------------------------- Changes (by simonmar):
* milestone: 6.12.2 => _|_ Comment: I rolled back the patch to libraries/base: {{{ Tue Feb 23 10:16:03 GMT 2010 Simon Marlow <marlo...@gmail.com> * UNDO: Handle NaN, -Infinity and Infinity in the toRational for Float/Double (#3676) }}} in retrospect it wasn't a good idea to shoehorn these strange values into Rational. The position now is that `toRational (1/0 :: Double)` is undefined. The Haskell standard does not define the result (it should), and GHC gives unpredictable results. Hence, `realToFrac` cannot convert accurately between floating-point types. Someone should: * propose a proer API for conversion between floating-point types, e.g. `FloatConvert` above, but make a full proposal. * decide whether `toRational (1/0::Double)` should be undefined or an exception. If it is an exception, then we cannot optimise `realToFrac` to a direct conversion, e.g. `floatToDouble#`. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3676#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs