[docs] BUG: A wrong result of computation in python2.6

Sandro Tosi sandro.tosi at gmail.com
Wed Feb 16 23:59:51 CET 2011


Hi Matthew,
thanks for your email.

On Wed, Feb 16, 2011 at 05:47, matthew chao <mathewchao at gmail.com> wrote:
> version: Python 2.6
> OS : Windows 7
>
> The variable x below should have been 10(integer) after the expression
> evaluates. It ,however, gets the value 10.000000000000002 (float) , as
> follows,
> --------------------------------------------
>>>> x=math.exp ( math.log(10.0))
>>>> x
> 10.000000000000002
>
>
>>>> x=math.exp ( math.log(10))
>>>> x
> 10.000000000000002
> --------------------------------------------
>
> In mathematics, the result is not right.

I could try to explain why this is "expected" on a computer, but I
could never do it even near as good as David Goldberg in his famous
paper "what every scientist should know about floating-point
arithmetic"[1]

[1] http://cr.yp.to/2005-590/goldberg.pdf

Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi


More information about the docs mailing list