class BsUtil {

    static long readFormattedLong(InputStream inputStream) throws IOException {
        long result = 0;
        for (int bitshift = 0; bitshift < 64; bitshift += 8) {
            result |= ((long) inputStream.read()) << bitshift;
        }

        if ((result - NEGATIVE_MASK) > 0) {
            result = (result & ~NEGATIVE_MASK) * -1;
        }
        return result;
    }

}