
30
•
A 3 byte encoded number can range from -131072 to +131071
Binary encoded numbers are always sent most significant bytes first. The number itself is broken
down into 6-bit digits, and each digit is placed in one byte of data. The number 64 (ASCII "@")
is added to each digit to make it fall within the range of displayable ASCII characters. The only
exception is that 127 (ASCII <DEL>) is sent as 63 (ASCII "?")
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".
Example 2
. Encoding the number 12345 in 3 bytes:
First we have to convert 12345 into binary in 6-bit pieces:
12345 (base 10) = 11 000000 111001 (base 2)
Now we can convert each piece back to base 10:
11 000000 111001 (base 2) = 3, 0, 57
Finally, we add 64 to each piece and convert to ASCII:
67, 64, 121 = ASCII "C@y"
Example 3
. Encoding the number -12345 in 3 bytes:
First we have to convert -12345 into two's complement 18-bit binary: -12345 (base 10) = 111100
111111 000111 (base 2)
Now we can convert each piece back to base 10: 111100 111111 000111 (base 2) = 60, 63, 7
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"
Example 4
. Decoding the 3 byte string "@SW":
This is just like encoding except we follow the steps backward.
First we convert all the characters to ASCII decimal codes:
ASCII "@SW" = 64, 83, 87
Now we subtract 64 from each piece and convert to 6-bit binary:
0, 19, 23 = 000000 010011 010111
Finally, we combine all the bits to form one 18-bit two’s complement number and convert to
base 10:
000000010011010111 = 1239
SHEF and SHEFFIX Formats
“SHEF” format conforms to NESDIS Standard Decimal format specifications. The format is
ASCII and readable by persons without the aid of a computer.