Skip to content

Packed Representations

stuarthalloway edited this page Nov 20, 2012 · 1 revision

Packed representations encode the type of a value and part of the value itself in a single byte. Fressian uses packed representations for integers, as well as for some small aggregate values.

Packed numbers

If you look at the Bytecodes table, you will see that the bytecodes from 0x00 to 0x40 directly represent the integers from 0x00 to 0x40. So for small integer values, both the type (integer) and the value are represented in a single byte.

Packed collections

Small collections can also have packed representations, where the bytecode indicates both the type and the length. For example, an array of a single byte 0x00 can be represented in Fressian as 0xd1 0x00, because the bytecode 0xd1 encodes "byte array of length 1".

Clone this wiki locally