Say I have the classic 4-byte signed integer, and I want something like
print hex(-1)
to give me something like
0xffffffff
In reality, the above gives me -0x1. I’m dawdling about in some lower level language, and python commandline is quick n easy.
So.. is there a way to do it?
This will do the trick:
or, a variant that always returns fixed size (there may well be a better way to do this):
Or, avoiding the hex() altogether, thanks to Ignacio and bobince: