2.6.1 - simple division

Tim Chase tim at thechases.com
Mon Mar 9 10:22:08 EDT 2009


farsight at gmail.com wrote:
>>>> 4 / 5.0
> 0.800000000000000004
>>>> 0.8 * 5
> 4.0

Start here:
http://docs.python.org/tutorial/floatingpoint.html


Play with these:

 >>> 4/5.0
0.800000000000000004
 >>> print 4/5.0
0.8
 >>> print repr(4/5.0)
0.800000000000000004
 >>> str(4/5.0)
'0.8'
 >>> repr(4/5.0)
'0.80000000000000004'


And learn more here:

http://www.lahey.com/float.htm

http://en.wikipedia.org/wiki/Floating-point


-tkc





More information about the Python-list mailing list