Unsigned integer arithmetic

Ray&Maria nospam at nowhere.net
Wed Apr 26 08:15:33 CEST 2000


> def printU32Hex(n):
>     if n > 0xffffffffL:
>         raise ValueError
>     print "0x%01x%07x" % (int(n >> 28), int(n & 0xfffffffL))

just in case someone send in int by mistake...

def printULHex(n):
    if n > 0xffffffffL or n < 0:
        raise ValueError
    print "0x%01x%07x" % (int(n >> 28), int(n & 0xfffffffL))






More information about the Python-list mailing list