[Haskell-beginners] How to convert a float or double number into a string?

Kim-Ee Yeoh ky3 at atamo.com
Thu Sep 19 18:39:41 CEST 2013


On Wed, Sep 18, 2013 at 8:14 PM, yi lu <zhiwudazhanjiangshi at gmail.com>wrote:

> What I need is just as much number of digits as possible. If I can hold as
> many digits of pi, i.e. 3.1415926535... as possible and save it in a
> String, it will be perfect!
>

Perhaps you had some experience with a computer algebra system (Maple,
Mathematica, etc.) and was expecting similar behavior?

While it's certainly possible to build it on top of Haskell, these kind of
floating-point features aren't available out of the box. Haskell provides
only fixed-bitwidth floating point.

As Oscar recommended, you probably want a String -> String function, say

> toEnglish "1.239402874"
"one point two three nine four zero blah blah"

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130919/92271c32/attachment.htm>


More information about the Beginners mailing list