code: def encode(self, value, length, signed):
          '''
          :param value: value to encode
          :param length: length of value in bits
          :param signed: is value signed
          '''
          if (length % 8 != 0) and self._mode:
              raise Exception('cannot use endianess for non bytes aligned int')
          pre = '' if signed else 'u'
          fmt = '%sint%s:%d=%d' % (pre, self._mode, length, value)
          return Bits(fmtf encode(self, value, length, signed):
          '''
          :param value: value to encode
          :param length: length of value in bits
          :param signed: is value signed
          '''
          if (length % 8 != 0) and self._mode:
              raise Exception('cannot use endianess for non bytes aligned int')
          pre = '' if signed else 'u'
          fmt = '%sint%s:%d=%d' % (pre, self._mode, length, value)
          return Bits(fmt)
docs: :param value: value to encode
          :param length: length of value in bits
          :param signed: is value signed