GHC: Ticket #5525: Mismatch between documentation and behaviour of encodeFloat
http://ghc.haskell.org/trac/ghc/ticket/5525
<p>
In the process of elaborating the docs to treat <a class="closed ticket" href="http://ghc.haskell.org/trac/ghc/ticket/3898" title="#3898: bug: Many floating point documentation/behaviour mismatches. (closed: fixed)">#3898</a>, I wrote
</p>
<pre class="wiki"> -- | '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 @&#177;Infinity@ if overflow occurs).
</pre><p>
Unfortunately, the last sentence is not quite true. If the end result is a subnormal number, <code>encodeFloat</code> performs two roundings, which may lead to a wrong result (can be 1 ulp off). Changing <code>encodeFloat</code> so that it always finds the closest representable number would cost a lot in performance, it would bring it close to <code>fromRational</code>. So the thing to do is change the docs, I just don't know how yet.
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/5525
Trac 1.2daniel.is.fischerSun, 02 Oct 2011 15:18:47 GMTstatus changed; resolution set
http://ghc.haskell.org/trac/ghc/ticket/5525#comment:1
http://ghc.haskell.org/trac/ghc/ticket/5525#comment:1
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>fixed</em>
</li>
</ul>
<p>
Fixed. Not overly elegant, but meh.
</p>
Ticket