code: public int readRawInt(int bits) throws IOException { 
          if (bits == 0) { return 0; }
          int uval = 0;
          for (int i = 0; i < bits; i++) {
              uval = readBitToInt(uval);
          }
          
          // fix the sign
          int val;
          int bitsToleft = 32 - bits;
          if (bitsToleft != 0) {
              uval <<= bitsToleft;
              val = uval;
              val >>= bitsToleft;
          } else {
              val = uval;
          }
          return val;
      }
docs: read bits into a signed integer.
  @param bits  The number of bits to read
  @return      The bits as a signed integer
  @throws IOException  Thrown if error reading input stream