easy float question just eludes me
Terry Reedy
tjreedy at udel.edu
Thu Jul 28 10:22:22 EDT 2005
<nephish at xit.net> wrote in message
news:1122557972.833617.157360 at o13g2000cwo.googlegroups.com...
> Hullo all !
>
> i have a real easy one here that isn't in my book.
> i have a int number that i want to divide by 100 and display to two
> decimal places.
>
> like this float(int(Var)/100)
At present, int/int truncates, so this won't do what you want. Use
int/100.0 to get float you want. For output, use % formating operator with
f specification.
>>> '%7.2f' % (50/100.0)
' 0.50'
Terry J. Reedy
More information about the Python-list
mailing list