hex to signed integer
tomg at em.ca
Thu Jul 17 18:48:55 CEST 2003
Tim Roberts wrote:
> Tom Goulet <tomg at em.ca> wrote:
>>I want to convert a string of hexadecimal characters to the signed
>>integer they would have been before the <print> statement converted
>>them. How do I do this in such a way that is compatible with Python
>>versions 1.5.2 through 2.4, and not machine-dependent?
> if hexbit < '8':
> temp = int(hexbit,16)
> temp = int(long(hexbit,16)-2**32)
The <int> function takes only one argument in Python 1.5.2.
Tom Goulet, tomg at em.ca, D8BAD3BC, http://web.em.ca/~tomg/contact.html
More information about the Python-list