/** * Read the next nb bits and return an Signed Long . * * @param nb the number of bits to convert to int, must be <= 64. * @return result * @throws java.io.IOException on read error */ 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 . * * @param nb the number of bits to convert to int, must be <= 64. * @return result * @throws java.io.IOException on read error */ 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; }