logoalt Hacker News

RedShift1today at 3:44 PM4 repliesview on HN

This seems quite convoluted just to avoid the "0 can be represented in more than one way" problem.


Replies

bjolitoday at 4:05 PM

Having all numbers be valid in only one way is a great idea. So much that I believe webassembly enforced canonical leb128, at the cost of decoding speed.

And say you have it as part of some other data. If you want to be able to hash it by the raw memory bytes, many different ways to represent a number becomes a problem.

nine_ktoday at 3:47 PM

It allows finding out the length (and allocating memory) after reading the first byte.

ape4today at 3:57 PM

Comparing a number to zero is something that's done a lot

show 1 reply
ahokatoday at 3:50 PM

I think it's neat.