Sutron Corporation X-Link Operations & Maintenance Manual, Rev 1.63 5/24/2016 pg. 162
16.6.1.
Example 1: Encoding the Number 10 in 1 Byte
Since 10 will fit in 6-bits we only have to add 64 which would yield 74. So the
number 10 would appear as ASCII 74 or the letter J.
16.6.2.
Example 2: Encoding the Number 12345 in 3 Bytes
1.
First we have to convert 12345 into binary in 6-bit pieces:
12345 (base 10) = 11 000000 111001 (base 2)
2.
Now we can convert each piece back to base 10:
11 000000 111001 (base 2) = 3, 0, 57
3.
Finally, we add 64 to each piece and convert to ASCII:
67, 64, 121 = ASCII C@y
16.6.3.
Example 3. Encoding the Number -12345 in 3 Bytes
1.
First we have to convert -12345 into two's complement 18-bit binary: -12345
(base 10) = 111100 111111 000111 (base 2)
2.
Now we can convert each piece back to base 10: 111100 111111 000111
(base 2) = 60, 63, 7
3.
Finally, we add 64 to each piece and convert to ASCII (since the second piece
is 63 we leave it alone):
124, 63, 71 = ASCII |?G
16.6.3.1.
Example 4. Decoding the 3 byte string @SW:
This is just like encoding except we follow the steps backward.
1.
First we convert all the characters to ASCII decimal codes:
ASCII @SW = 64, 83, 87
2.
Now we subtract 64 from each piece and convert to 6-bit binary:
0, 19, 23 = 000000 010011 010111
3.
Finally, we combine all the bits to form one 18-bit two’s complement number
and convert to base 10:
000000010011010111 = 1239