Weird arithmetic in Python

rzantow at my-deja.com rzantow at my-deja.com
Mon Oct 30 09:13:37 EST 2000


In article <slrn8vpahn.be6.kc5tja at garnet.armored.net>,
  kc5tja at armored.net wrote:
> On Sun, 29 Oct 2000 22:39:17 GMT, yminsky at cs.cornell.edu wrote:
> >>>> .1 * 3 - .3
> >5.55111512313e-17
>
> Round-off error.  The computer is incapable of representing certain
numbers
> with full fidelity.  Evaluating 0.1*3 loses some precision over just
typing
> in 0.3, so the difference in precision is the result you see above
> (5.55111512313e-17).
>
I comprehend that roundoff error could readily produce non-zero answers.
But what sort of roundoff causes .1 * 3 - .3 to be greater than 5?

--
Pythons, unlike some other snakes, do have hindlimbs, but they never
develop beyond vestigial stumps. The arrest of limb development is
due to a failure of the sonic hedgehog signalling system ...


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list