Python fails on math

Duncan Booth duncan.booth at invalid.invalid
Tue Feb 22 15:25:34 CET 2011

christian schulze <xcr4cx at> 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)

See the Python FAQ:

Duncan Booth

More information about the Python-list mailing list