Repair varint() definition in cheatsheet
This commit is contained in:
parent
f47786871c
commit
5d0bf91d30
|
@ -19,10 +19,8 @@ For a value `V`, we write `«V»` for the binary encoding of `V`.
|
|||
«#{E_1...E_m}» = [0xB6] ++ «E_1» ++...++ «E_m» ++ [0x84]
|
||||
«{K_1:V_1...K_m:V_m}» = [0xB7] ++ «K_1» ++ «V_1» ++...++ «K_m» ++ «V_m» ++ [0x84]
|
||||
|
||||
varint(v) = e(v, 128)
|
||||
|
||||
e(v, d) = [v + d] if v < 128
|
||||
e(v >> 7, 0) ++ [(v & 0x7F) + d] if v ≥ 128
|
||||
varint(v) = [v] if v < 128
|
||||
[(v & 0x7F) + 128] ++ varint(v >> 7) if v ≥ 128
|
||||
|
||||
The functions `binary32(F)` and `binary64(D)` yield big-endian 4- and
|
||||
8-byte IEEE 754 binary representations of `F` and `D`, respectively.
|
||||
|
|
Loading…
Reference in New Issue