def hex(number, prefix="0x"):
  """
  Converts a integer value to its hexadecimal representation.

  :param number:
      Integer value.
  :param prefix:
      The prefix to use for the hexadecimal string. Default "0x" to mimic
      ``hex()``.
  :returns:
      Hexadecimal string.
  """
  prefix = prefix or ""
  if number < 0:
    number = -number
    prefix = "-" + prefix

  # Make sure this is an int and not float.
  _ = number & 1

  hex_num = "%x" % number
  return prefix + hex_num.lower()