code: def decint(n, signed=False):  # pylint: disable=invalid-name,too-many-branches
      
  
      if isinstance(n, str):
          n = utils.to_string(n)
  
      if n is True:
          return 1
  
      if n is False:
          return 0
  
      if n is None:
          return 0
  
      if is_numeric(n):
          if signed:
              if not -TT255 <= n <= TT255 - 1:
                  raise EncodingError('Number out of range: %r' % n)
          else:
              if not 0 <= n <= TT256 - 1:
                  raise EncodingError('Number out of range: %r' % n)
  
          return n
  
      if is_string(n):
          if len(n) > 32:
              raise EncodingError('String too long: %r' % n)
  
          if len(n) == 40:
              int_bigendian = decode_hex(n)
          else:
              int_bigendian = n  # pylint: disable=redefined-variable-type
  
          result = big_endian_to_int(int_bigendian)
          if signed:
              if result >= TT255:
                  result -= TT256
  
              if not -TT255 <= result <= TT255 - 1:
                  raise EncodingError('Number out of range: %r' % n)
          else:
              if not 0 <= result <= TT256 - 1:
                  raise EncodingError('Number out of range: %r' % n)
  
          return result
  
      raise EncodingError('Cannot decode integer: %r' % n)
docs: Decode an unsigned/signed integer.