Dealing with hex
Dan Bishop
danb_83 at yahoo.com
Wed Dec 10 22:29:26 EST 2003
More information about the Python-list mailing list
Wed Dec 10 22:29:26 EST 2003
- Previous message (by thread): Dealing with hex
- Next message (by thread): Dealing with hex
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Derrick 'dman' Hudson <dman at dman13.dyndns.org> wrote in message news:<6clka1-ksi.ln1 at dman13.dyndns.org>... > On Wed, 10 Dec 2003 03:49:16 GMT, Matt Gerrans wrote: > > Is there an ideal approach to dealing with the FutureWarning about getting > > the hex value of a negative int? I'm using zlib.crc32() which can return > > a negative 32-bit int value, so for example print '%x' % zlib.crc32( > > buffer ) generates the FutureWarning. I know I could jump through hoops > > to coerce the int into a long that will have the same CRC, but is there some > > particular recomendation for this (I looked at PEP 237, but there wasn't a > > suggestion). > > Hoops? For example : > print "%x" % long( zlib.crc32( buffer ) ) > > That seems simple enough to me. Or if you wanted the old semantics: def unsigned(n): return n & 0xFFFFFFFFL print "%x" % unsigned(zlib.crc32(buffer))
- Previous message (by thread): Dealing with hex
- Next message (by thread): Dealing with hex
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list