Hexadecimal floating point literals

How is 0x12.2P2 equal to 72.5?

I know that the value following P, called the binary exponent, indicates a power-two by which the number is multiplied?

+6
source share
1 answer

0x12.2P2 - 0x122 / 16 10 * 2 2

  • 0x122 = 290 10
  • divided by 16 10 = 18.125 10
  • times 2 2 leads to 72.5 10

More formally (?), For the part up to P , you can use this very classic conversion table:

  decimal point here ▼ +-----+-----+-----+-----+-+-----+-----+-----+ | 16³ | 16² | 16¹ | 16| | 16⁻¹| 16⁻²| 16⁻³| +-----------------------------------------+ | | | 1 | 2 |.| 2 | | | +-----+-----+-----+-----+-+-----+-----+-----+ 

Thus, 0x12.2 is 1⨯16¹ + 2x16⁰ + 2⨯16⁻¹ = 18.125

+16
source

Source: https://habr.com/ru/post/974940/


All Articles