christian schulze <xcr...@googlemail.com> wrote: > Hey guys, > > I just found out, how much Python fails on simple math. I checked a > simple equation for a friend. > > [code] >>>> from math import e as e >>>> from math import sqrt as sqrt >>>> 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) > False > [/code] > Try the same in other languages and you'll get the same result. Here's Javascript (checked on Chrome and Firefox, IE crashed):
> 2*Math.E*Math.sqrt(3)-2*Math.E==2*Math.E*(Math.sqrt(3)-1) false See the Python FAQ: http://docs.python.org/faq/design.html#why-are-floating-point-calculations-so-inaccurate -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list