Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

ZigZag encoding

Name: Anonymous 2016-09-04 10:53

Name: Anonymous 2016-09-04 17:50

*hits joint*

Name: Anonymous 2016-09-04 18:11

And here is 300 – this is a bit more complicated:

1010 1100 0000 0010
How do you figure out that this is 300? First you drop the msb from each byte, as this is just there to tell us whether we've reached the end of the number (as you can see, it's set in the first byte as there is more than one byte in the varint):

1010 1100 0000 0010
→ 010 1100 000 0010
You reverse the two groups of 7 bits because, as you remember, varints store numbers with the least significant group first. Then you concatenate them to get your final value:

000 0010 010 1100
→ 000 0010 ++ 010 1100
→ 100101100
→ 256 + 32 + 8 + 4 = 300


da fuq? just use 2s complement bitch

Don't change these.
Name: Email:
Entire Thread Thread List