public static Int64 Decode(DecodeBuffer input) { // This was difficult to get right, translated from https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/wire_format_lite.h var n = UnsignedVlq.Decode(input); return((Int64)((n >> 1) ^ (~(n & 1) + 1))); }
public static ArraySegment <Byte> Encode(Int64 value) { return(UnsignedVlq.Encode((UInt64)((value << 1) ^ (value >> 63)))); // (n << 1) ^ (n >> 63) }