Documentation Inquiry (varint)
(1) By anonymous on 2023-07-28 20:37:54 [source]
Hi there, I'm spending some time learning about the SQLite internals and I came across a bit of documentation that is either mistaken or I'm not understanding it correctly. Below is the Github link to the source (using github because I can link directly to the line).
In this particular example, 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678 is incorrect given my understanding of varints. Full breakdown below:
0x8a - 1 0001010 0x91 - 1 0001010 0xd1 - 1 1010001 0xac - 1 0101100 0x78 - 0 1111000
Using the 7 bits following each leading bit you get the following sequence:
00010100001010101000101011001111000 which translates to 0xa1545678. The sequence is the same as the example from the digit '4' onward, but the first three digits do not match.
Is my calculation incorrect or is this documentation faulty?
(2) By Roy Hashimoto (rhashimoto) on 2023-07-28 20:46:08 in reply to 1 [link] [source]
0x91 - 1 0001010
0x91 is 10010001
(4) By anonymous on 2023-07-28 20:55:54 in reply to 2 [link] [source]
Oh nice catch!
This brings the end result closer to 0xa2345678, but the first digit is still off. Should the line start 0x81 instead of 0x8a?
(6.1) By Larry Brasfield (larrybr) on 2023-07-28 21:41:21 edited from 6.0 in reply to 4 [link] [source]
Should the line start 0x81 instead of 0x8a?
Yes, I believe so. Fixed here.
(7) By anonymous on 2023-07-29 14:12:21 in reply to 6.1 [link] [source]
oh nice, thanks for the quick patch!
(3) By Stephan Beal (stephan) on 2023-07-28 20:47:19 in reply to 1 [link] [source]
using github because I can link directly to the line).
(5) By anonymous on 2023-07-28 20:56:06 in reply to 3 [link] [source]