Comment

Comment by ridiculous_fish

VLQ decoding is sort of subtle, and the one shown in the article under "Base 64 Variable Length Quantities" looks broken.

1. `shift` can grow large, and an overlong left shift will panic in Rust. I expect an input like "gggggggC" to crash.

2. `accum >>= 1` is wrong because it rounds down. It needs to be a round-towards-zero: `accum /= 2`.

3. `accum` is a 32 bit int which is too small. It needs to be larger so it can represent -2^31 in sign-magnitude form.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton