[GHC] #9564: Floating point subnormals overrounded on output

GHC ghc-devs at haskell.org
Sat Sep 13 11:38:38 UTC 2014


#9564: Floating point subnormals overrounded on output
-------------------------------------+-------------------------------------
              Reporter:  jrp         |            Owner:
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:
             Component:  Runtime     |          Version:  7.8.3
  System                             |         Keywords:
            Resolution:              |     Architecture:  x86_64 (amd64)
      Operating System:  MacOS X     |       Difficulty:  Unknown
       Type of failure:  Incorrect   |       Blocked By:
  result at runtime                  |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by jrp):

 For the record, looking through the code, libraries/base/GHC/Float.lhs
 seems to use {{{FloatToDigits}}} to generate the decimal representation.
 The algorithm used is "based on"

    "Printing Floating-Point Numbers Quickly and Accurately"-- by R.G.
 Burger and R.K. Dybvig in PLDI 96.  http://www.cs.indiana.edu/~dyb/pubs
 /FP-Printing-PLDI96.pdf This version uses a much slower logarithm
 estimator. It should be improved.

 In turn, that algorithm was based on "How to Print Floating-Point Numbers
 Accurately" by Steele and White
 http://kurtstephens.com/files/p372-steele.pdf but it does not distinguish
 between significand and insignifican trailing zeros.

 The latest approach to conversion appears to be "Printing Floating-Point
 Numbers Quickly and Accurately with Integers" by Florian Loitsch
 http://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf
 (Bryan O'Sullivan http://www.serpentine.com/blog/2011/06/29/here-be-
 dragons-advances-in-problems-you-didnt-even-know-you-had/  has provided a
 library for the Double version  http://hackage.haskell.org/package/double-
 conversion.)

 For a full set of references, including to source code, see
 http://www.ryanjuckett.com/programming/printing-floating-point-numbers/

 I'll have a further think about this, including rwbarton's comments.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9564#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list