#5525: Mismatch between documentation and behaviour of encodeFloat
----------------------------------+-----------------------------------------
    Reporter:  daniel.is.fischer  |       Owner:                   
        Type:  bug                |      Status:  new              
    Priority:  normal             |   Component:  libraries/base   
     Version:  7.3                |    Keywords:                   
    Testcase:                     |   Blockedby:                   
          Os:  Unknown/Multiple   |    Blocking:                   
Architecture:  Unknown/Multiple   |     Failure:  Documentation bug
----------------------------------+-----------------------------------------
 In the process of elaborating the docs to treat #3898, I wrote
 {{{
     -- | 'encodeFloat' performs the inverse of 'decodeFloat' in the
     -- sense that for finite @x@ with the exception of @-0.0@,
     -- @'uncurry' 'encodeFloat' ('decodeFloat' x) = x@.
     -- @'encodeFloat' m n@ is the closest representable floating-point
     -- number to @m*b^^n@ (or @±Infinity@ if overflow occurs).
 }}}
 Unfortunately, the last sentence is not quite true. If the end result is a
 subnormal number, `encodeFloat` performs two roundings, which may lead to
 a wrong result (can be 1 ulp off). Changing `encodeFloat` so that it
 always finds the closest representable number would cost a lot in
 performance, it would bring it close to `fromRational`. So the thing to do
 is change the docs, I just don't know how yet.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5525>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to