Sha256: d71d016e8f162c71e5651eace432fa9844193d938adf6548c2f98f7331ca4c95

Contents?: true

Size: 1.22 KB

Versions: 60

Compression:

Stored size: 1.22 KB

Contents

The goal of this exercise is to implement [VLQ](https://en.wikipedia.org/wiki/Variable-length_quantity) encoding/decoding.

In short, the goal of this encoding is to encode integer values in a way that would save bytes.
Only the first 7 bits of each byte is significant (right-justified; sort of like an ASCII byte). 
So, if you have a 32-bit value, you have to unpack it into a series of 7-bit bytes. 
Of course, you will have a variable number of bytes depending upon your integer. 
To indicate which is the last byte of the series, you leave bit #7 clear.
In all of the preceding bytes, you set bit #7. 

So, if an integer is between `0-127`, it can be represented as one byte. 
The largest integer allowed is `0FFFFFFF`, which translates to 4 bytes variable length. 
Here are examples of delta-times as 32-bit values, and the variable length quantities that they translate to:


```
 NUMBER        VARIABLE QUANTITY
00000000              00
00000040              40
0000007F              7F
00000080             81 00
00002000             C0 00
00003FFF             FF 7F
00004000           81 80 00
00100000           C0 80 00
001FFFFF           FF FF 7F
00200000          81 80 80 00
08000000          C0 80 80 00
0FFFFFFF          FF FF FF 7F
```

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
trackler-2.0.6.4 common/exercises/variable-length-quantity/description.md
trackler-2.0.6.3 common/exercises/variable-length-quantity/description.md
trackler-2.0.6.2 common/exercises/variable-length-quantity/description.md
trackler-2.0.6.1 common/exercises/variable-length-quantity/description.md
trackler-2.0.6.0 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.18 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.17 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.16 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.15 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.14 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.13 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.12 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.11 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.10 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.9 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.8 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.7 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.6 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.5 common/exercises/variable-length-quantity/description.md
trackler-2.0.5.4 common/exercises/variable-length-quantity/description.md