<div dir="ltr"><br clear="all"><a href="http://ik.homelinux.org/">http://ik.homelinux.org/</a><br>
<br><br><div class="gmail_quote">On Mon, Mar 1, 2010 at 23:20, Jerry <span dir="ltr"><<a href="mailto:lanceboyle@qwest.net">lanceboyle@qwest.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;">Don't compare floating points. Ever. Now you see why.</div></blockquote><div><br>So if I need for example to compare currency or something that is floating point, how do I do that ?<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><br></div><div>Also, don't write loops that calculate a floating point number which is then tested for equality to exit the loop. Also, it is a bad idea to test for > or < for exiting unless you know in advance an accidental equality result will not yield surprising results. In other other words, don't do that (test for > or <) either.</div>
</div></blockquote><div><br>As I understand, there is an old way to calculate floating point that is very popular and newer ways for that.<br>The old way uses binary calculation and the newer I do not understand them :)<br>
<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;"><div><br></div><div>Jerry</div><div><br><div>
<div><div></div><div class="h5"><div>On Feb 26, 2010, at 3:37 AM, ik wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5"><div dir="ltr">Hello,<br><br>I've made a small test:<br><br>if (0.1+0.2) = 0.3 then<br>
<br>The only compiler/interpator that actually tells that it equal is FPC.<br><br>I've tested it using Javascript (in Firefox), Ruby, Python, C (gcc) and Perl.<br> <br>Except FPC, everyone tells that 0.1+0.2 = 0.30000000000000004<br>
<br>Can someone explain how FPC see the result and why others does not see it like that ?<br><br><br>Thanks,<br>Ido<br><br clear="all"><a href="http://ik.homelinux.org/" target="_blank">http://ik.homelinux.org/</a><br> </div>
</div></div><div class="im"> _______________________________________________<br>fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a></div>
</blockquote></div><br></div></div><br>_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br></blockquote></div><br><br>Ido<br></div>