Re: Decimal Places Incorrect

2005-06-08 Thread Dan Bishop
Tom Haddon wrote: > Hi Folks, > > When I run: > > print "%0.2f" % ((16160698368/1024/1024/1024),) > > I get 15.00 > > I should be getting 15.05. Can anyone tell me why I'm not? Because you forgot to use "from __future__ import division". -- http://mail.python.org/mailman/listinfo/python-list

Re: Decimal Places Incorrect

2005-06-08 Thread Christopher Subich
Tom Haddon wrote: > Hi Folks, > > When I run: > > print "%0.2f" % ((16160698368/1024/1024/1024),) > > I get 15.00 > > I should be getting 15.05. Can anyone tell me why I'm not? Short answer: Integer division. Long answer: Integer division. 16160698368/1024 = 15781932L 15781932L/1024 =

Re: Decimal Places Incorrect

2005-06-08 Thread Robert Kern
Tom Haddon wrote: > Hi Folks, > > When I run: > > print "%0.2f" % ((16160698368/1024/1024/1024),) > > I get 15.00 > > I should be getting 15.05. Can anyone tell me why I'm not? Integer division does not yield floats. http://docs.python.org/lib/typesnumeric.html -- Robert Kern [EMAIL PROTECT

Decimal Places Incorrect

2005-06-08 Thread Tom Haddon
Hi Folks, When I run: print "%0.2f" % ((16160698368/1024/1024/1024),) I get 15.00 I should be getting 15.05. Can anyone tell me why I'm not? Thanks, Tom -- http://mail.python.org/mailman/listinfo/python-list