[Tutor] Hex strings

Ivan Van Laningham ivanlan@callware.com
Sun, 25 Jul 1999 14:27:17 -0600


Hi All--

Jon Cosby wrote:
> 
> How do you go about manipulating these hexadecimal strings, for example,
> adding two numbers base 16?
> 

n = string.atoi("0xFFFF",16)
n = n + 0xFFFF
print n

The optional second argument to string.atoi() is the base from which you
wish to convert.

Once strings are converted to integers, they're just computer numbers;
you only have to worry about the radix (base) when you want to read them
in or print them out.  By default, atoi() and print assume you want to
read and see them in decimal.

<there's-bedrock-under-that-thar-quicksand>-ly y'rs,
Ivan
----------------------------------------------
Ivan Van Laningham
Callware Technologies, Inc.
ivanlan@callware.com
ivanlan@home.com
http://www.pauahtun.org
See also: 
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
----------------------------------------------