On Mon, Jul 11, 2016, at 16:06, Michael Torrie wrote: > I'm not sure I've ever seen a negative hex number in the wild. Usually > when I view a number in hex I am wanting the raw representation. -0x123 > with a width of 7 would be 0xFFEDD
There's nothing "raw" about python int objects. To get what you want, you need to do x & 0xfffff If you have "5" as a parameter, you can get the desired constant as (1 << x*4) - 1. -- https://mail.python.org/mailman/listinfo/python-list