visad/src/main/java/ucar/nc2/iosp/gempak/GempakGridReader.java
private int bits2UInt(int nb) throws IOException {
    int bitsLeft = nb;
    int result = 0;

    if (bitPos == 0) {
      //bitBuf = raf.read();
      getNextByte();
      bitPos = 8;
    }

    while (true) {
      int shift = bitsLeft - bitPos;
      if (shift > 0) {
        // Consume the entire buffer
        result |= bitBuf << shift;
        bitsLeft -= bitPos;

        // Get the next byte from the RandomAccessFile
        //bitBuf = raf.read();
        getNextByte();
        bitPos = 8;
      } else {
        // Consume a portion of the buffer
        result |= bitBuf >> -shift;
        bitPos -= bitsLeft;
        bitBuf &= 0xff >> (8 - bitPos);  // mask off consumed bits

        return result;
      }
    }                                        // end while
  }
private int bits2UInt(int nb) throws IOException {
    int bitsLeft = nb;
    int result = 0;

    if (bitPos == 0) {
      //bitBuf = raf.read();
      getNextByte();
      bitPos = 8;
    }

    while (true) {
      int shift = bitsLeft - bitPos;
      if (shift > 0) {
        // Consume the entire buffer
        result |= bitBuf << shift;
        bitsLeft -= bitPos;

        // Get the next byte from the RandomAccessFile
        //bitBuf = raf.read();
        getNextByte();
        bitPos = 8;
      } else {
        // Consume a portion of the buffer
        result |= bitBuf >> -shift;
        bitPos -= bitsLeft;
        bitBuf &= 0xff >> (8 - bitPos);  // mask off consumed bits

        return result;
      }
    }                                        // end while
  }
private int bits2UInt ( int nb ) throws IOException { int bitsLeft = nb ; int result = 0 ; if ( bitPos == 0 ) { //bitBuf = raf.read(); getNextByte ( ) ; bitPos = 8 ; } while ( true ) { int shift = bitsLeft - bitPos ; if ( shift > 0 ) { // Consume the entire buffer result |= bitBuf << shift ; bitsLeft -= bitPos ; // Get the next byte from the RandomAccessFile //bitBuf = raf.read(); getNextByte ( ) ; bitPos = 8 ; } else { // Consume a portion of the buffer result |= bitBuf >> - shift ; bitPos -= bitsLeft ; bitBuf &= 0xff >> ( 8 - bitPos ) ; // mask off consumed bits return result ; } } // end while }
Convert bits (nb) to Unsigned Int .

@param nb number of bits
@return int of BinaryDataSection section
@throws IOException
Convert bits ( nb ) to Unsigned Int .