
#14425: approxRational is wrong when (rat - eps) overflows in negative direction -------------------------------------+------------------------------------- Reporter: danielk | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: | Version: 8.2.1 libraries/base | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect result Unknown/Multiple | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This program is wrong. The second output should be 0 % 1. {{{ import Data.Ratio main = do print (approxRational (0 % 1 :: Ratio Int) (1 % 10)) -- 0%1, correct print (approxRational (0 % 1 :: Ratio Word) (1 % 10)) -- 1%1, incorrect }}} The problem is that (rat-eps) overflows in the negative direction (see [http://hackage.haskell.org/package/base-4.10.0.0/docs/src/Data.Ratio.html#ap... source]). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14425 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler