Protobuf's encoding uses three bit-level operations: byte order, bit shifting, and bitwise OR. If you can already read x << 3 | y, skip ahead. If not, here's the short version.
Further Reading
- Endianness
Little- and big-endian byte order, and why it matters when bytes move between machines.
- Bit shifts
The shift operations behind the tag formula, including the arithmetic/logical distinction this page glosses over.
- Bitwise OR
How OR merges bit patterns, along with the AND and XOR operations decoders also use.
Next
Base-128 Varints
How Protobuf base-128 varints encode integers in as few bytes as possible: continuation bits, byte layout, and an interactive varint encoder.