def parseNum(num):
  """0x or $ is hex, 0b is binary, 0 is octal. Otherwise assume decimal."""
  num = str(num).strip()
  base = 10
  if (num[0] == '0') & (len(num) > 1):
    if num[1] == 'x':
      base = 16
    elif num[1] == 'b':
      base = 2
    else:
      base = 8
  elif num[0]=='$':
    base = 16
  return int(num, base)