Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 views
in Technique[技术] by (71.8m points)

floating point - 64 Bit Hex conversion to decimal

I have a 16 Bit hex value:

4164ACFCE33404EA

After conversion, the number is:

10840039.1001

I've tried both IEEE single and double precision 64-bit to decimal and a variety of 16 bit two compliment conversions with no luck. Any Ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The hexadecimal value in your question shows the bits used to represent a floating-point number in the IEEE-754 basic 64-bit binary format.

The first bit, 0, is the sign. 0 means positive.

The next 11 bits, 41616, encode the exponent. 41616 is 104610. The code is biased by 1023, meaning the actual power of 2 it represents is 21046?1023 = 223.

The remaining 52 bits encode the significand (fraction) portion of the number. These bits are 4ACFCE33404EA16. To get the actual significand from this code, we write them as “1.” followed by the code: 1.4ACFCE33404EA16. In decimal, this is 1.29223335982561104984256417083088308572769165039062510.

When we multiply the significand by 223, the result is 10840039.1000999994575977325439453125. That is the value represented by the bits 4164ACFCE33404EA16.

Notes

The use of “1.” with the significand is for normal numbers, where the encoded exponent is not 0 or its maximum value. If the exponent code is zero, the number is either zero or subnormal, and “0.” is used with the significand instead. If the exponent code is its maximum value (2047 for the 64-bit format), the floating-point object represents either an infinity (if all the significand bits are zero) or a NaN.

In the 64-bit format, the hexadecimal digits happen to line up with the border between the exponent field and the significand field. In other formats, such as the 32-bit format, you would have to shift some bits to separate the fields, instead of just extracting hexadecimal digits visually.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...