简体   繁体   中英

How do I convert a hexadecimal number in IEEE 754 double precision (64bit) format to a decimal number?

My task is to convert a hexadecimal number in double precision format (IEEE 754) on a paper. I've converted a hexadecimal number: 0x40790A0000000000 to a binary 64bit format so far and now I have: 0 10000000111 1001000010100000000000000000000000000000000000000000

For the next step I am not totally sure what to do. I have to convert it into a decimal number and I've tried out several ways, but never got the right result. Hope you can help me and thank you.

Going from https://en.wikipedia.org/wiki/Double-precision_floating-point_format ,

4    0    7    9    0    A    0    0    0    0    0    0    0    0    0    0
0100 0000 0111 1001 0000 1010 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0 - Sign bit (this is a positive number)
 100 0000 0111 - Exponent
               1001 0000 1010 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 - Fraction

The exponent's value is 1031. Because it's nonzero the fractional part is given by the expression 1 + sum from i = 1 to 52 bit_(52-i) * 2^(-i).

The fraction's value is therefore 1 + 1/2 + 0/4 + 0/8 + 1/16 + ... ~= 1.56

From there you should be able to figure the rest out.

(Not solving this completely because this looks like homework.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM