You may want to restrict the result to certain limit in the floating numbers <div><br></div><div>each system has its own levels of floating numbers and even a small difference is a difference to return FALSE <br><br><div class="gmail_quote">
On Tue, Feb 22, 2011 at 6:50 PM, christian schulze <span dir="ltr"><<a href="mailto:xcr4cx@googlemail.com">xcr4cx@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hey guys,<br>
<br>
I just found out, how much Python fails on simple math. I checked a<br>
simple equation for a friend.<br>
<br>
[code]<br>
>>> from math import e as e<br>
>>> from math import sqrt as sqrt<br>
>>> 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1)<br>
False<br>
[/code]<br>
<br>
So WTF? The equation is definitive equivalent. (See <a href="http://mathbin.net/59158" target="_blank">http://mathbin.net/59158</a>)<br>
<br>
PS:<br>
<br>
#1:<br>
>>> 2.0 * e * sqrt(3.0) - 2.0 * e<br>
3.9798408154464964<br>
<br>
#2:<br>
>>> 2.0 * e * (sqrt(3.0) -1.0)<br>
3.979840815446496<br>
<br>
I was wondering what exactly is failing here. The math module? Python,<br>
or the IEEE specifications?<br>
<br>
--<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Nitin Pawar<br><br>
</div>