Skip to content
Discussion options

You must be logged in to vote

@swang373 — Thank you — that’s a great direction to explore.

Firstly, Protobuf encodes negative int32 values as 10‑byte varints. This is a quirk of Protobuf’s varint design:

  • Protobuf varints are unsigned.
  • int32 fields are not zigzag‑encoded.
  • So negative values are encoded as their two’s‑complement 64‑bit representation, which always requires 10 bytes.

For -1, the varint is:

ff ff ff ff ff ff ff ff ff 01

This is exactly what you saw.

Protobuf’s decoder is perfectly happy with this because it always reads varints into a uint64 and then casts down to the declared type.

Secondly, AwkwardForth’s varint-> instruction is intentionally limited. AwkwardForth’s varint reader is designed for Awkwa…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ianna
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants