"Eric Morey" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
Hello everyone,

I have no prior experience with programing. I've just started with the
Python tutorial at http://www.dickbaldwin.com/tocpyth.htm.
On the section that describes decimal division on this page:
http://www.dickbaldwin.com/python/Pyth0004.htm

Figure 10 shows:

       >>> 2.0/5 # get decimal quotient
       0.4
       >>> 2/5.0 # do it again
       0.4
       >>>

http://www.dickbaldwin.com/python/Pyth0004-fig10.htm


Howerver, using the python shell in my terminal, I get:
       >>> 2.0/5 # get decimal quotient
       0.40000000000000002
       >>> 2/5.0 # do it again
       0.40000000000000002
       >>>

I didn't worry too much about it and continued to move on. But I'm
curious as to why there was a difference. Anyone know why?

http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate

-Mark

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to