Convert '165.0' to int

rantingrick rantingrick at
Fri Jul 22 21:32:00 CEST 2011

On Jul 22, 7:42 am, Hrvoje Niksic <hnik... at> wrote:
> Frank Millman <fr... at> writes:
> > int(float(x)) does the job, and I am happy with that. I was just
> > asking if there were any alternatives.
> int(float(s)) will corrupt integers larger than 2**53, should you ever
> need them.  int(decimal.Decimal(s)) works with numbers of arbitrary
> size.


>>> '{0:,.0f}'.format(2**53)

That's nine-quadrillion people! Only for galactic measurements or
microscopic reasons would you need such large numbers.

PS: GAWD i love that new string format function!

More information about the Python-list mailing list