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

yi lu zhiwudazhanjiangshi at gmail.com
Wed Sep 18 17:12:25 CEST 2013


This<https://github.com/eccstartup/numberToText/blob/master/src/Text/New/NumberToText.hs#L104>is
my poor code.
*show* function truncated these digits.


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

> You are right! I hope to input a number, for example 123, and output its
> text "one hundred and twenty-three".
> So, for 1.23456789012345678901, I want the result is "one point two three
> four five six ...(something omitted)".
> I can define a funciton, say "toText", to preform this action.
> In ghci, I can use like this.
> Prelude>toText 123.45
> "one hundred and twenty-three point four five"
>
> However, in this function, I have to read this number as String(originally
> a number, now "123"), and make it to words(String) like "one two three".
> But for a float number, it will not work very well.
> Prelude>toText 1.23456789012345678901
> "(a truncated answer)"
>
> This confuses me!
>
> Yi
>
>
> On Wed, Sep 18, 2013 at 10:23 PM, Oscar Benjamin <
> oscar.j.benjamin at gmail.com> wrote:
>
>>
>> On Sep 18, 2013 2:15 PM, "yi lu" <zhiwudazhanjiangshi at gmail.com> wrote:
>> >
>> > In fact, I am not looking for some way to convert a float 0.75 to 3%4.
>> Your reply is helpful!
>> > 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!
>>
>> I think something is still missing from your description.
>>
>> If you want to store the digits of pi in a string then why not use a
>> string?
>>
>> Oscar
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130918/a8f07c2e/attachment.htm>


More information about the Beginners mailing list