public long bits2SInt ( int nb ) throws IOException { long result = bits2UInt ( nb ) ; // check if we're negative if ( getBit ( result , nb ) ) { // it's negative! reset leading bit result = setBit ( result , nb , false ) ; // build 2's-complement result = ~ result & LONG_BITMASK ; result = result + 1 ; } return result ; }
Read the next nb bits and return an Signed Long .