转换IEEE 754浮点数到1750计算机浮动 [英] Converting IEEE 754 Float to MIL-STD-1750A Float

查看:302
本文介绍了转换IEEE 754浮点数到1750计算机浮动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个IEEE 754 32位单precision浮点值(标准C浮点变量)转换为一个无符号长变量的 MIL-STD-1750A 。我已经包含在文章底部的两个IEEE 754和MIL-STD-1750A规范。现在,我有我的code问题与转换的指数。我也看到问题与转换尾数,但我还没有得到到固定的呢。我使用上面的链接表3中列出的例子,以确认我的程序正确地转换。其中的一些例子没有意义了我。


  1. 这两个例子中怎么能有相同的指数?

      .5,×2 ^ 0(0100 0000 0000 0000 0000 0000 0000 0000)
    1×2 ^ 0(1000 0000 0000 0000 0000 0000 0000 0000)

    .5,×2 ^ 0有一个小数位,和-1没有小数位,所以对于价值0.5×2 ^ 0应

      .5,×2 ^ 0(0100 0000 0000 0000 0000 0000 0000 0010)

    吧? (0010,而不是0001,因为1750A用途加1偏差)


  2. 如何能在最后一个示例使用全部32位,第一位是1,表示为负值?

      0.7500001x2 ^ 4(1001 1111 1111 1111 1111 1111 0000 0100)


  3. 我可以看到,与127指数的值应该是7楼(0111 1111)但对于具有负127指数的值?难道是81(1000 0001)?如果是这样,是不是因为那是两个互补的127 +1?


感谢您


解决方案

  

1)这两个例子怎么可以有相同的指数?


据我了解,符号和尾数有效范围内定义一个二进制补码值[-1.0,1.0)。

当然,这将导致多余重presentations(0.125 * 2 1 = 0.25 * 2 0 等),因此,一个规范的标准化重presentation被选择,通过在范围不允许尾数值[-0.5,0.5)

因此​​,在你的两个例子,无论是-1.0和0.5落入允许尾数范围内,所以他们都共享相同的指数值。


  

2)如何能在最后一个示例使用全部32位,第一位是1,表示为负值?


这是不正确的看向我。你是如何获得重新presentation?


  

3)什么用负127指数的值?难道是81(1000 0001)?


我相信如此。

I am trying to convert a IEEE 754 32 bit single precision floating point value (standard c float variable) to an unsigned long variable in the format of MIL-STD-1750A. I have included the specification for both IEEE 754 and MIL-STD-1750A at the bottom of the post. Right now, I am having issues in my code with converting the exponent. I also see issues with converting the mantissa, but I haven't gotten to fixing those yet. I am using the examples listed in Table 3 in the link above to confirm if my program is converting properly. Some of those examples do not make sense to me.

  1. How can these two examples have the same exponent?

    .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 has no 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 1750A uses plus 1 bias)

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

    0.7500001x2^4 (1001 1111 1111 1111 1111 1111 0000 0100)
    

  3. I can see that a value with a 127 exponent should be 7F (0111 1111) but what about a value with a negative 127 exponent? Would it be 81 (1000 0001)? If so, is it because that is the two's complement +1 of 127?

Thank you

解决方案

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

As I understand it, the sign and mantissa effectively define a 2's-complement value in the range [-1.0,1.0).

Of course, this leads to redundant representations (0.125*21 = 0.25*20, etc.) So a canonical normalized representation is chosen, by disallowing mantissa values in the range [-0.5,0.5).

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

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

That doesn't look right to me; how did you obtain that representation?

3) What about a value with a negative 127 exponent? Would it be 81 (1000 0001)?

I believe so.

这篇关于转换IEEE 754浮点数到1750计算机浮动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆