Convert IEEE 754 Float to MIL-STD-1750A Float

I am trying to convert a 32-bit single precision IEEE 754 floating point value (standard variable c float) to an unsigned long variable in the format MIL-STD-1750A . I have included the specification for IEEE 754 and MIL-STD-1750A at the bottom of the post. Right now I am having problems with my exponent conversion code. I also see problems with the conversion of the mantissa, but I have not yet been able to fix them. I use the examples listed in table 3 in the link above to confirm whether my program is being converted correctly. Some of these examples do not make sense to me.

  • How can these two examples have the same metric?

    .5 x 2^0 (0100 0000 0000 0000 0000 0000 0000 0000) -1 x 2^0 (1000 0000 0000 0000 0000 0000 0000 0000) 

    .5 x 2 ^ 0 has one decimal place, and -1 does not have decimal places, so the value for .5 x 2 ^ 0 should be

     .5 x 2^0 (0100 0000 0000 0000 0000 0000 0000 0010) 

    right? (0010 instead of 0001 because the 1750A uses plus 1 offset)

  • How can the last example use all 32 bits and the first bit is 1, indicating a negative value?

     0.7500001x2^4 (1001 1111 1111 1111 1111 1111 0000 0100) 
  • I see that the value with the exponent 127 should be 7F (0111 1111), but what about the value with the negative exponent 127? Would it be 81 (1000 0001)? If so, is it because these are two additions +1 of 127?

thanks

1750ASpecification

+4
source share
2 answers

1) How can these two examples have the same indicator?

As I understand it, the sign and the mantissa effectively determine the value of the 2'-complement in the range [-1.0,1.0].

Of course, this leads to redundant representations (0.125 * 2 1 = 0.25 * 2 0 , etc.). Thus, the canonical normalized representation is chosen, prohibiting the mantissa values ​​in the range [-0,5,0,5).

So, in your two examples, both -1.0 and 0.5 fall into the "allowed" range of the mantissa, so both of them have the same exponent value.

2) How can the last example use all 32 bits and the first bit is 1, indicating a negative value?

This does not look right to me; How did you get this view?

3) How about a negative value of 127? Would it be 81 (1000 0001)?

I think so.

+1
source
  • Remember that a fraction is a "signed fraction". Values ​​signed are stored in the format of 2 additions. So think of zeros as them. So a number can be written as -0.111111111111111111111 (base 2) x 2 ^ 0, which is close to one (converges to 1.0 if my math is correct)

  • In the last example, there is a negative sign in the original document (-0.7500001x2 ^ 4)

0
source

All Articles