Convert 500.0 from the decimal representation to a representation with base 2. In contrast to IEEE, DSP normalizes the mantissa between 0 and 1 and not between 1 and 2. This makes it possible to also represent 0, which must have a special pattern in IEEE. In addition, the exponent is different from IEEE.
value = (-1)^s * m*2^e
where:
For 500 this gives:
Next convert the mantissa into its binary representation (as shown in the following listing).
mant (500.0, DSP) = 0.9765625 (dec) = 0*2^(0) + 1*2^(-1) + 1*2^(-2) + 1*2^(-3) + 1*2^(-4) + 1*2^(-5) + 0*2^(-6) + 1*2^(-7) + 0*.... = 0.1111101000... (bin)
Because this number is always greater than or equal to 0 and less than 1, there is always a 0 in front of the decimal point. For the remaining steps this constant is omitted to save space. There is always a 1 after the decimal point, except for 0 and intermediate results. This bit is encoded so the DSP loses one additional bit of precision compared with IEEE.
mant (500.0, DSP, cut) = .1111101000...
The exponent must also be converted to binary format:
exp (500.0, DSP) = 9 == 09 (hex) == 1001 (bin)
Negative exponents are encoded by the base 2 representation of the positive value.
The sign is encoded into the mantissa by taking the two's complement for negative numbers and placing a bit set to 1 in the front. For DSP and positive numbers, a bit cleared to 0 is added at the front.
mant(500.0, DSP) = 0111110100000000 (bin)
The two's complement is taken for negative numbers:
mant(-500.0, DSP) = 1000001100000000 (bin)
Finally the mantissa and the exponent must be joined according to the following listing.
= 7D 00 (mantissa) 00 09 (exponent) (DSP as hex) = 7D 00 00 09 (DSP as hex) = 0111 1101 0000 0000 0000 0000 0000 1001 (DSP as binary)
The following listing shows the DSP representation of decimal -500.
= 83 00 (mantissa) 00 09 (exponent) (DSP as hex) = 83 00 00 09 (DSP as hex) = 1000 0011 0000 0000 0000 0000 0000 1001 (DSP as binary)