64位十六进制转换为十进制 [英] 64 Bit Hex conversion to decimal

查看:1131
本文介绍了64位十六进制转换为十进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个16位十六进制值:


4164ACFCE33404EA


转换后的数字为:


10840039.1001


我尝试了IEEE单精度和双精度64位到十进制以及各种16位的两次称赞转换,但是都没有运气。有任何想法吗?

解决方案

问题中的十六进制值显示了IEEE-754基本64-位中用于表示浮点数的位位二进制格式。



第一位是符号。 0表示正数。



接下来的11位416 16 对指数进行编码。 416 16 是1046 10 。该代码有1023的偏差,表示它代表2的实际次幂是2 1046−1023 = 2 23



剩余的52位对数字的有效(分数)部分进行编码。这些位是4ACFCE33404EA 16 。为了从该代码中获得实际的有效位数,我们将其写为 1。后跟代码:1.4ACFCE33404EA 16 。用十进制表示,这是1.292233359825611049842564170830883085727691650390625 10 。 。那是由4164ACFCE33404EA 16 位表示的值。



注释



使用 1。有效数字表示标准数字,其中编码的指数不为0或其最大值。如果指数代码为零,则数字为零或非正规数,即为 0。与有意义的数字一起使用。如果指数代码是最大值(对于64位格式为2047),则浮点对象将表示无穷大(如果所有有效位均为零)或NaN。



在64位格式中,十六进制数字恰好与指数字段和有效字段之间的边界对齐。在其他格式(例如32位格式)中,您将不得不移位一些位以分隔字段,而不是仅仅视觉上提取十六进制数字。


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?

解决方案

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.

这篇关于64位十六进制转换为十进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆