def bin(number, prefix='0b'):
    """
  Converts a long value to its binary representation.

  :param number:
      Long value.
  :param prefix:
      The prefix to use for the bitstring. Default "0b" to mimic Python
      builtin ``bin()``.
  :returns:
      Bit string.
  """
    if number is None:
        raise TypeError("'%r' object cannot be interpreted as an index" %
            type(number).__name__)
    prefix = prefix or ''
    if number < 0:
        number = -number
        prefix = '-' + prefix
    bit_string = ''
    while number > 1:
        bit_string = str(number & 1) + bit_string
        number >>= 1
    bit_string = str(number) + bit_string
    return prefix + bit_string
