unsigned integers

Paul Rubin http
Thu Mar 6 12:35:25 EST 2003


"Giovanni Bajo" <noway at sorry.com> writes:
> 1) How can I force 0xFFFFFFFF to be 4294967295 instead of -1? 

Say 0xFFFFFFFFL (the trailing L makes the literal into a long integer).

> 2) binascii.crc32() returns a signed integer representing the CRC. I call it
> signed because if I print the result it displays a signed number. Now, what
> if I need the unsigned representation of it (as in, the unsigned number
> which is machine-represented with the same 32 bits)? I need to multiply it
> by another integer, but I need an unsigned multiplication, not a signed one.

crc = binascii.crc32(...)
if crc < 0:
   crc += 0x100000000L

or something like that.




More information about the Python-list mailing list