Re: easy float question just eludes me
- From: "Terry Reedy" <tjreedy@xxxxxxxx>
- Date: Thu, 28 Jul 2005 10:22:22 -0400
<nephish@xxxxxxx> wrote in message
news:1122557972.833617.157360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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
.
- References:
- easy float question just eludes me
- From: nephish
- easy float question just eludes me
- Prev by Date: Re: On fighting fire with fire...
- Next by Date: Re: retrieve data from 2 database
- Previous by thread: Re: easy float question just eludes me
- Next by thread: baffling error-handling problem
- Index(es):
Relevant Pages
|