<div dir="ltr"><div>In fact, I am not looking for some way to convert a float 0.75 to 3%4. Your reply is helpful! <br>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!<br>

<br></div>Yi<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 18, 2013 at 9:00 PM, Oscar Benjamin <span dir="ltr">&lt;<a href="mailto:oscar.j.benjamin@gmail.com" target="_blank">oscar.j.benjamin@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 18 September 2013 13:48, yi lu &lt;<a href="mailto:zhiwudazhanjiangshi@gmail.com">zhiwudazhanjiangshi@gmail.com</a>&gt; wrote:<br>

&gt; If I use `show`,<br>
&gt; show 123.45, it will return &quot;123.45&quot;, a desired answer.<br>
&gt;<br>
&gt; However, for<br>
&gt; show 123.45678901234567890, it will return<br>
&gt; &quot;123.45678901234568&quot;.<br>
&gt;<br>
&gt; I want to save all digits into a string. I suppose I use a wrong type of<br>
&gt; number, which is Float.<br>
<br>
</div>Yes, it is the wrong type of number. Float can only store finitely<br>
many digits and you&#39;re asking for slightly too many. Also even if it<br>
*looks like* float has enough digits for your number in fact it has<br>
converted them from decimal to binary. For non-integers exact decimal<br>
to binary conversion is rarely possible. In this case the nearest<br>
binary float is 123.4567890123456805895330035127699375152587890625 but<br>
many of these decimal digits will be truncated from display.<br>
<div class="im"><br>
&gt; But what can I do to work right?<br>
<br>
</div>Are rational numbers acceptable in your problem?<br>
<a href="http://stackoverflow.com/questions/7056791/how-to-parse-a-decimal-fraction-into-rational-in-haskell" target="_blank">http://stackoverflow.com/questions/7056791/how-to-parse-a-decimal-fraction-into-rational-in-haskell</a><br>

<br>
<br>
Oscar<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>