Decimal Places Incorrect

Robert Kern rkern at ucsd.edu
Wed Jun 8 20:46:56 EDT 2005


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
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list