This question already has answers here:
Java floating-point numbers representation as a hexadecimal numbers

(2个答案)



In binary notation, what is the meaning of the digits after the radix point “.”?

(7个答案)


已关闭6年。



0x12.2P2如何等于72.5?

我知道P后面的值称为二进制指数,它表示数字乘以2的幂。

最佳答案

0x12.2P2为0x122/1610 * 22

  • 0x122 = 29010
  • 除以1610 = 18.12510
  • 乘以22导致72.510


  • 更正式地说(?),对于P之前的部分,您可以使用以下非常经典的转换表:
         decimal point here  ▼
    +-----+-----+-----+-----+-+-----+-----+-----+
    | 16³ | 16² | 16¹ | 16⁰ | | 16⁻¹| 16⁻²| 16⁻³|
    +-----------------------------------------+
    |     |     |  1  |  2  |.|  2  |     |     |
    +-----+-----+-----+-----+-+-----+-----+-----+
    

    所以0x12.2是1⨯16¹+2x16⁰+2⨯16⁻¹= 18.125

    10-04 22:23