TinyVG / specification

The specification for TinyVG. This is the central authority for the file system

Home Page:https://tinyvg.tech/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VarUInt read() example is incorrect

pluick opened this issue · comments

If I understand the VarUInt spec correctly, the 7th bit is set to indicate that this is the final bit of data. The example read() function seems to indicate the opposite (7th bit unset indicates the final bit). The example code should change from 0 -> 1, e.g.

if ((byte & 0x80) == 0)
    break;

change to

if ((byte & 0x80) == 1)
    break;

No, the VarUInt function is correct, what is the problem is my bad description of that decoding and a typo. The last byte must have 0x0? as the upper byte, not 0x8?

Also, your new code here is definitly wrong, and you should use 0x80 in the comparison

if ((byte & 0x80) == 0x80) // 1 is never a possible value here!
    break;

Oops, you are right about the bitmask.

So I was reading the description wrong and the changes should be something like this?:

-Bytes are read until the uppermost bit in the byte is set
+Bytes are read until the uppermost bit in the byte is not set

and about the final byte:

-This byte must always have the uppermost 4 bits set as 0b1000????.
+This byte must always have the uppermost 4 bits set as 0b0000????.

yep, that is correct

This should be fixed now