I found my answer anyways...
#define decode_sint32(n) (((n) >> 1) ^ (-((n) & 1)))
On Saturday, September 5, 2015 at 9:13:00 PM UTC-6, Ilia Mirkin wrote:
>
>
> https://developers.google.com/protocol-buffers/docs/encoding#signed-integers
>
> This is all documented. Please read the docs.
>
> On
On Sat, Sep 5, 2015 at 9:36 PM, TheAceInfinity wrote:
> If I know that the bytes are a type of varint from a byte stream, is there
> then no way to determine whether the 150 should be calculated and
> interpreted as an int32 or an sint32?
Nope, no information beyond the wire
Here is parts of my code:
#define WIRE_TYPE_VARINT 0x0 /* int32, int64, uing32, uint64,
sint32, sint64, bool, enum */
...
#define GET_WIRE_TYPE(v) ((v) & 0x7)
But when I parse the wire type to determine that the bytes *0x08, 0x96,
0x01* refer to a varint, is there anything
https://developers.google.com/protocol-buffers/docs/encoding#signed-integers
This is all documented. Please read the docs.
On Sat, Sep 5, 2015 at 11:08 PM, TheAceInfinity wrote:
> I wrote these helper macros for s types:
> #define encode_sint32(n) (((n) << 1) ^ ((n) >> 31))
I have read the docs a bunch of times. If I didn't I wouldn't have posted
these questions quoting portions of the page's text. What I'm asking has to
do with the decoding process, those bit manipulations describe the encoding
process only AFAIK.
On Saturday, September 5, 2015 at 9:13:00 PM
No I wrote some C code which will determine varint from that byte stream,
and give me a value of 150. What I was wondering was more along the lines
of what you're talking about here: "Of course there's no way to tell the
difference between, say, an int32 or sint32 (which uses zigzag encoding),
I suppose that answers my question then. I was thinking it might be the tag
id that determines the specific wire_type subtype, but I guess not.
On Saturday, September 5, 2015 at 7:41:05 PM UTC-6, Ilia Mirkin wrote:
>
> On Sat, Sep 5, 2015 at 9:36 PM, TheAceInfinity > wrote:
I wrote these helper macros for s types:
#define encode_sint32(n) (((n) << 1) ^ ((n) >> 31))
#define encode_sint64(n) (((n) << 1) ^ ((n) >> 63))
Do you have any information on how to go about decoding the bytes if my
original type was sint32 or sint64?
On Saturday, September 5, 2015 at 7:41:05