#4383: Uncanonical display of Double ----------------------------------+----------------------------------------- Reporter: daniel.is.fischer | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 6.12.3 | Keywords: Double, show Testcase: | Blockedby: Os: Unknown/Multiple | Blocking: Architecture: Unknown/Multiple | Failure: Incorrect result at runtime ----------------------------------+-----------------------------------------
Comment(by daniel.is.fischer): For starters, a better approximation to logBase 10 2 fixes this, {{{ if b == 2 && base == 10 then -- logBase 10 2 is slightly bigger than 3/10 so -- the following will err on the low side. Ignoring -- the fraction will make it err even more. -- Haskell promises that p-1 <= logBase b f < p. -- (p - 1 + e0) * 3 `div` 10 (p - 1 + e0) * 21306 `quot` 70777 *FloatShow> let x :: Double; x = 0.5 ^ 1030 *FloatShow> floatToDigits 10 x ([8,6,9,1,6,9,4,7,5,9,7,9,4],-310) *FloatShow> showFloat x "" "8.691694759794e-311" }}} but I'd rather check the code carefully to see whether something else might need fixing (and maybe an earlier convergent of logBase 10 2 will suffice). -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4383#comment:2> 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