GSOF messages: Reading binary values (Motorola format)

The receivers store numbers in Motorola format. The byte order of these numbers is the opposite of what personal computers (Intel format) expect. To supply or interpret binary numbers (8-byte DOUBLES, 4-byte LONGS, and 2-byte INTEGERS), the byte order of these values must be reversed. This section contains a detailed description of the Motorola format.

INTEGER data types

The INTEGER data types (CHAR, SHORT, and LONG) can be signed or unsigned. By default, they are unsigned. All integer data types use two’s complement representation. The following table lists the integer data types:

Type

# of bits

Range of values (Signed)

Unsigned

Char

8

-128 to 127

0 to 255

Short

16

-32768 to 32767

0 to 65535

Long

32

–2147483648 to 2147483647

0 to 4294967295

FLOATING-POINT data types

Floating-point data types are stored in the IEEE SINGLE and DOUBLE precision formats. Both formats have a sign bit field, an exponent field, and a fraction field. The fields represent floating-point numbers in the following manner:

Floating-Point Number = <sign> 1.<fraction field> x 2(<exponent field> - bias)

Sign bit field

The sign bit field is the most significant bit of the floating-point number. The sign bit is 0 for positive numbers and 1 for negative numbers.

Fraction field

The fraction field contains the fractional part of a normalized number. Normalized numbers are greater than or equal to 1 and less than 2. Since all normalized numbers are of the form 1.XXXXXXXX, the 1 becomes implicit and is not stored in memory. The bits in the fraction field are the bits to the right of the binary point, and they represent negative powers of 2. For example:

0.011 (binary) = 2-2 + 2-3 = 0.25 + 0.125 = 0.375

Exponent field

The exponent field contains a biased exponent; that is, a constant bias is subtracted from the number in the exponent field to yield the actual exponent. (The bias makes negative exponents possible.)

If both the exponent field and the fraction field are zero, the floating-point number is zero.

NaN

A NaN (Not a Number) is a special value that is used when the result of an operation is undefined. For example, adding positive infinity to negative infinity results in a NaN.

FLOAT data type

The FLOAT data type is stored in the IEEE single-precision format which is 32 bits long. The most significant bit is the sign bit, the next 8 most significant bits are the exponent field, and the remaining 23 bits are the fraction field. The bias of the exponent is 127. The range of single-precision format values is from 1.18 x 10–38 to 3.4 x 1038. The floating-point number is precise to 6 decimal digits.

0 000 0000 0 000 0000 0000 0000 0000 0000 = 0.0
0 011 1111 1 000 0000 0000 0000 0000 0000 = 1.0
1 011 1111 1 011 0000 0000 0000 0000 0000 = -1.375
1 111 1111 1 111 1111 1111 1111 1111 1111 = NaN

DOUBLE

The DOUBLE data type is stored in the IEEE double-precision format which is 64 bits long. The most significant bit is the sign bit, the next 11 most significant bits are the exponent field, and the remaining 52 bits are the fractional field. The bias of the exponent is 1023. The range of single precision format values is from 2.23 × 10–308 to 1.8 × 10308. The floating-point number is precise to 15 decimal digits.

0 000 0000 0000 0000 0000 ... 0000 0000 0000 = 0.0
0 011 1111 1111 0000 0000 ... 0000 0000 0000 = 1.0
1 011 1111 1110 0110 0000 ... 0000 0000 0000 = -0.6875
1 111 1111 1111 1111 1111 ... 1111 1111 1111 = NaN