[Tutor] hex to decimal conversion.
Magnus Lycka
magnus@thinkware.se
Fri Nov 15 04:48:02 2002
At 09:09 2002-11-15 +0100, Gregor Lingl wrote:
>Thomi Richards schrieb:
>>can anyone tell me how to convert from hexidecimal to decimal??
>> >>> int(0xff)
>255
> >>> int(0x3e8)
>1000
> >>> int("ff",16)
>255
> >>> int("3e8",16)
>1000
Or for big ones:
>>> long('fffffffffff',16)
17592186044415L
These long and int conversions work for bases up to 36:
>>> long('j',20)
19L
>>> long('k',20)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
ValueError: invalid literal for long(): k
>>> long('k',21)
20L
>>> int('z',36)
35
--
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se