core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/binary/OVarIntSerializer.java
public static long readSignedVarLong(final BytesContainer bytes) {
    final long raw = readUnsignedVarLong(bytes);
    // This undoes the trick in writeSignedVarLong()
    final long temp = (((raw << 63) >> 63) ^ raw) >> 1;
    // This extra step lets us deal with the largest signed values by
    // treating
    // negative results from read unsigned methods as like unsigned values
    // Must re-flip the top bit if the original read value had it set.
    return temp ^ (raw & (1L << 63));
  }
public static long readSignedVarLong(final BytesContainer bytes) {
    final long raw = readUnsignedVarLong(bytes);
    // This undoes the trick in writeSignedVarLong()
    final long temp = (((raw << 63) >> 63) ^ raw) >> 1;
    // This extra step lets us deal with the largest signed values by
    // treating
    // negative results from read unsigned methods as like unsigned values
    // Must re-flip the top bit if the original read value had it set.
    return temp ^ (raw & (1L << 63));
  }
public static long readSignedVarLong ( final BytesContainer bytes ) { final long raw = readUnsignedVarLong ( bytes ) ; // This undoes the trick in writeSignedVarLong() final long temp = ( ( ( raw << 63 ) >> 63 ) ^ raw ) >> 1 ; // This extra step lets us deal with the largest signed values by // treating // negative results from read unsigned methods as like unsigned values // Must re-flip the top bit if the original read value had it set. return temp ^ ( raw & ( 1L << 63 ) ) ; }
@param bytes to read bytes from

@return decode value

@throws IllegalArgumentException if variable-length value does not terminate after 9 bytes have been read
@param bytes to read bytes from