Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes: >> Is this right? >> >> n = int('0xC0A8', 16) >> if n >= 0xffff: >> n -= 0x10000 > No.
Oops, I meant n >= 0x7fff. Checking the sign bit. Grant Edwards <invalid@invalid.invalid> writes: > Yes, as long as the input value doesn't exceed 0x1ffff. This is > probably better: > > n = int('0xc0a8'16) & 0xffff Yeah, I was relying on the specification that the input was 16 bits. -- http://mail.python.org/mailman/listinfo/python-list