<div dir="ltr">Thanks!<div>I'll try CReal.<br><div>But can I set <strong style="font-size:13px;font-weight:normal;color:rgb(204,0,0);font-family:Arial,Helvetica,sans-serif;line-height:18px">significant figures </strong><strong style="font-size:13px;font-weight:normal;font-family:Arial,Helvetica,sans-serif;line-height:18px"><font color="#000000">myself?</font></strong></div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 6, 2013 at 6:50 AM, Brandon Allbery <span dir="ltr"><<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div class="h5">On Tue, Feb 5, 2013 at 5:41 PM, yi lu <span dir="ltr"><<a href="mailto:zhiwudazhanjiangshi@gmail.com" target="_blank">zhiwudazhanjiangshi@gmail.com</a>></span> wrote:<br>
</div></div><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>I found that in ghci, I input </div><div>[0.1,0.2..2]<br></div><div>and run, I get a result of </div><div><br></div><div>[0.1,0.2,0.30000000000000004,0.4000000000000001,0.5000000000000001,0.6000000000000001,0.7000000000000001,0.8,0.9,1.0,1.1,1.2000000000000002,1.3000000000000003,1.4000000000000004,1.5000000000000004,1.6000000000000005,1.7000000000000006,1.8000000000000007,1.9000000000000008,2.000000000000001]</div>
<div><br></div><div>But, as you know, it is not the exact answer.</div><div><br></div><div>So, I wonder if there is something I can do to achieve a better performance and get <span style="background-color:rgb(153,153,153)">[0.1,0.2,0.3,0.4..]</span> as the result.</div>
</div></blockquote><div><br></div></div></div><div>Welcome to the world of floating point numbers. Perfect accuracy is not possible; the CReal type from the "numbers" package may handle cases you care about, or may not. (Other languages often use output formats that can largely hide the errors, but they're still there and will eventually accumulate into visibility.)</div>
<span class="HOEnZb"><font color="#888888">
<div><br></div></font></span></div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div>
<div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</font></span></div>
<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>
<br></blockquote></div><br></div>