public static Long getLongNullable(ByteBuffer in)
    {
        int a = in.get() & 0xFF;

        if (a == NULL) 
        {
            return null;
        }
        
        int sign = (a & BYTE_SIGN_NEG);
        long value = (a & 0x1FL);
        int shift = -2;
        
        while ((a & BYTE_MORE) != 0)
        {
            a = in.get() & 0xFF;
            value |= (a & 0x7FL) << (shift += 7);
        }
        
        if (sign != 0)
        {
            value = -value;
        }
        
        return value;
    }