views:

70

answers:

1

I am trying to convert an IEEE based floating point number to a MIL-STD 1750A floating point number.

I have attached the specification for both: alt text

I understand how to decompose the floating point 12.375 in IEEE format as per the example on wikipedia.

However, I'm not sure if my interpretation of the MIL-STD is correct.

12.375 = (12)b10 + (0.375)b10 = (1100)b2 + (0.011)b2 = (1100.011)b2 (1100.011)b2 = 0.1100011 x 2^4 => Exponent, E = 4.

4 in normalised 2's complement is = (100)b2 = Exponent

Therefore a MIL-STD 1750A 32 bit floating point number is:

S=0, F=11000110000000000000000, E=00000100

Is my above interpretation correct?

For -12.375, is it just the sign bit that swaps? i.e.:

S=1, F=11000110000000000000000, E=00000100

Or does something funky happen with the fraction part?

+3  A: 

The diagram above is a bit misleading, I think. In IEEE format, to switch from positive to negative, you simply flip the first bit. The remaining three bits can be treated as an unsigned number. In the MIL-STD format, the mantissa is a two's complement number, so while the first bit does indicate the sign, the remaining 23 bits do not remain the same.

What I get is

S=1, F=00111010000000000000000, E=00000100
Tristan
so it seems you make the fraction 1100011 2's complement => 0011101, however the remaining bits in the fraction component are still 0's?
Seth
Yes, to take the two's complement negation, take the bitwise NOT and add one: so when you take the bitwise not, you end up with 16 1's on the far right, then when you add one, they all carry over.
Tristan
+1 right of course. thanks.
Seth