WOLFRAM NOTEBOOK

WOLFRAM|DEMONSTRATIONS PROJECT

Self-Delimiting Binary Representation of a Ternary List

focus
random seed
10946593
5828854
8003854
6406826
13151948
14067039
8673551
13037577
3500015
6908225
13408207
10385165
11167464
4000555
9892375
12202868
8755534
15342049
9788821
7240276
1160075
10263080
14054102
14088781
ternary number with delimiter
self-delimited binary representation of ternary with delimiter
A list of numbers can be stored as one binary number which concatenates their self-delimiting representations. The numbers do not have be aligned by padding them and there is no need for extra delimiter characters.
This Demonstration stores 24 numbers. Their self-delimited ternary representations are encoded as base 3 digits. Each of the base 3 digits is represented by a pair of binary digits. The fourth possible pair of binary digits represents the delimiter. This delimiter marks the end of each number in the given list of numbers.
You can choose another set of 24 numbers. Each is given by 24 bits. Click on one of the 24 numbers to see its ternary representation and the binary encoding of its self-delimited ternary representation. Note that its self-delimited representation always ends with 2 black pixels.
The left plot at the bottom shows the 24-bit aligned binary representations for the 24 numbers. The binary representations of these numbers are aligned by padding them with zeros. The right plot shows the binary encoding of the self-delimited ternary representation for the same numbers.
Note that the self-delimiting representation needs more bits but no alignment. The gray pixels in the bottom right plot fill the ragged array of bits which results from partitioning the concatened bits of the 24 self-delimiting representations.
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.