十六进制浮点文字 [英] Hexadecimal Floating-point literals
本文介绍了十六进制浮点文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
0x12.2P2
如何等于72.5?
我知道P后面的值叫做二进制指数,表示数乘以2的幂数?
解决方案
0x12。 2P2
是0x122 / 16 <10> * 2
- 0x122 = 290 10
- 除以16 10 = 18.125 10
li乘以2 2导致72.5 10
在
P
之前的部分更正式(?),您可以使用这个经典换算表:
小数点在这里▼
+ ----- + ----- + - ---- + ----- + - + ----- + ----- + ----- +
| 16³| 16²| 16¹| 16⁰| | 16⁻¹| 16⁻²| 16⁻³|
+ ----------------------------------------- +
| | | 1 | 2 |。| 2 | | |
+ ----- + ----- + ----- + ----- + - + ----- + ----- + ----- +
所以0x12.2是1⨯16¹+2x16⁰+2⨯16¹= 18.125
How does
0x12.2P2
equal 72.5?I know that the value following the P, called the binary exponent, indicates the power-of-two by which the number is multiplied?
解决方案0x12.2P2
is 0x122 / 1610 * 22- 0x122 = 29010
- divided by 1610 = 18.12510
- multiplied by 22 leads to 72.510
More formally (?), for the part before the
P
, you can use this very classic conversion table:decimal point here ▼ +-----+-----+-----+-----+-+-----+-----+-----+ | 16³ | 16² | 16¹ | 16⁰ | | 16⁻¹| 16⁻²| 16⁻³| +-----------------------------------------+ | | | 1 | 2 |.| 2 | | | +-----+-----+-----+-----+-+-----+-----+-----+
So 0x12.2 is 1⨯16¹+2x16⁰+2⨯16⁻¹ = 18.125
这篇关于十六进制浮点文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文