Convert '165.0' to int
rantingrick
rantingrick at gmail.com
Fri Jul 22 15:32:00 EDT 2011
On Jul 22, 7:42 am, Hrvoje Niksic <hnik... at xemacs.org> wrote:
> Frank Millman <fr... at chagford.com> 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.
Correct!
>>> '{0:,.0f}'.format(2**53)
'9,007,199,254,740,992'
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