I use Python to handle some large integers (64-bit, unsigned). I'm trying to convert a string of values to integers. However my Python3 gave me incorrect results. For example, if I convert an input string of "12736193479609682490" to integer, the result is not what I expected:
a = '12736193479609682490'
b = int(float(a))
>>>b
12736193479609681920
I'm usng Python 3.4.0 under ubuntu 12.04-64bit. What should I do to make a correct conversion? Thanks.
Don't convert to float first.
>>> int("12736193479609682490")
12736193479609682490
That number is too big to store in a float accurately!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments