I was wondering if theres any easy and fast way to obtain the decimal value of a signed hex in python.
What I do to check the value of a hex code is just open up python in terminal and type in the hex, it returns the decimal like this:
>>>0x0024
36
>>>0xcafe
51966
So I was wondering, is there any way that I could do that for signed short hex? for example 0xfffc should return -4
import ctypes
def hex2dec(v):
return ctypes.c_int16(v).value
print hex2dec(0xfffc)
print hex2dec(0x0024)
print hex2dec(0xcafe)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With