开发者

Questions about two's complement and IEEE 754 representations

How would i go about finding the value of the two-byte two’s complement value 0xFF72 is"?

  1. Would i st开发者_如何学运维art by converting 0xFF72 to binary?
  2. reverse the bits.
  3. add 1 in binary notation. // lost here.
  4. write decimal.

I just dont know..

Also,

What about an 8 byte double that has the value: 0x7FF8000000000000. Its value as a floating point?


I would think that this was homework, but for the particular double that is listed. 0x7FF8000000000000 is a quiet NaN per the IEEE-754 spec, not a very interesting value to put on a homework assignment:

  • The sign bit is clear.
  • The exponent field is 0x7ff, the largest possible exponent, which means that the number is either an infinity or a NaN.
  • The significand field is 0x8000000000000. Since it isn't zero, the number is not an infinity, and must be a NaN. Since the leading bit is set, it is a quiet NaN, not a so-called "signaling NaN".


Step 3 just means add 1 to the value. It's really as simple as it sounds. :-)

Example with 0xFF72 (assumed 16-bits here):

  1. First, invert it: 0x008D (each digit is simply 0xF minus the original value)
  2. Then add 1: 0x008E


This sounds like homework and for openness you should tag it as such if it is.

As for interpreting an 8 byte (double) floating point number, take a look at this Wikipedia article.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜