Converting between hexadecimal, decimal and binary in Python:

  • hex2dec: int(a, 16)
  • dec2hex: hex(a)
  • bin2dec: int(a, 2)
  • dec2bin: there seems to be no such function, so I wrote my own (5 lines)

Converting between hex and bin then is a two-step process

Advertisements