1.6, tutorial, and floating point (was Re: varibles)

Aahz Maruch aahz at panix.com
Wed Sep 20 23:00:30 EDT 2000


[posted with cc to python-docs; not sure who is responsible for the
tutorial these day.]

In article <Kkcy5.7276$7g.244130 at news3.mia>,
Brendhan Horne <brendhan at bellsouth.net> wrote:
>
>Okay another episode of help the newbie.
>In the tutorial this example exists:
>>>>tax=17.5/100
>>>>price= 3.50
>>>>price*tax
>0.6125
>>>>price+_
>4.1125
>>>>round(_,2)
>4.11
>
>What happens is it is off by .0001
>instead I get
>0.612499999999993

The tutorial is out of date.  The actual math has not changed, but the
way floating point numbers are displayed has changed in 1.6.  See

http://www.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=607818947

for an article by Tim Peters on the subject.
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Member of the Groucho Marx Fan Club  --Aahz



More information about the Python-list mailing list