如何将这些字节转换为浮动?

发布于 2025-01-17 10:21:31 字数 208 浏览 4 评论 0原文

\ x00 \ x16 7g

\ x8d \ xed 6g

\ x1a \ x16 7g

\ x00 \ x00 \ x16 7g

5e 7g

这些是btcusdt的价格数据。因此,也许像44xxxxx.xxx 45xxxx.xxx一样。这个数字如何制造?我听不懂。我只知道\ x是六NUMBER,其他可能是ASCII代码。

\x00 \x16 7G

\x8d \xed 6G

\x1a \x16 7G

\x00 \x16 7G

5E 7G

These is BTCUSDT PRICE data.. so maybe presented like 44xxx.xxx 45xxx.xxx. How can this number make? I can't understand. What i only know is \x is hexnumber and others are maybe ASCII CODES.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧瑾黎汐 2025-01-24 10:21:31

您拥有的字节是IEEE-754编码46870、46829.55078125、46870.1015625、46870和46917.20703125。

要解码它们,请按小订单将字节复制到float对象中,然后将它们解释为float对象。如何执行此操作的详细信息将取决于所使用的编程语言,该问题不指出。

要手动解码它们,请写出每个四个字节的32位,首先是第四个字节的位(在高价值位置),​​然后是第三个字节的位,然后是第二个字节,然后是第一个。从这32位,将第一个作为标志位 s 。将接下来的八个作为指数代码 e 的位。将最后23个作为显着的代码 f 的位。

解码符号位:让 s =(-1) s

解码指数位:将它们解释为未签名的八位数字, e 。然后:

  • 如果 e 为255,而 f 为零,则根据 s 为+1或-1。解码完成了,停止。
  • 如果 e 为255,而 f 不是零,则数据代表nan(不是数字),而 f 包含补充信息。在典型的实现中,如果设置了 f 的高点,则NAN是一个安静的,否则是信号。解码完成,停止。
  • 如果 e 为零,请让 e = -126和令 f = 0。
  • 否则,否则,令 e = < em> e -127和令 f = 1。

解码显着范围:令 f = f f + f •2 -23

表示的数字为 s f •2 e

The bytes you have are IEEE-754 encodings of the numbers 46870, 46829.55078125, 46870.1015625, 46870, and 46917.20703125.

To decode them, copy the bytes into a float object in little-endian order, then interpret them as that float object. Details of how to do this will depend on the programming language used, which the question does not state.

To decode them manually, write out the 32 bits of each four bytes, with the bits of the fourth byte first (in the high-value positions), then the bits of the third byte, then the second, then the first. From those 32 bits, take the first one as a sign bit s. Take the next eight as bits for an exponent code e. Take the last 23 as bits for a significand code f.

Decode the sign bit: Let S = (−1)s.

Decode the exponent bits: Interpret them as an unsigned eight-bit numeral, e. Then:

  • If e is 255 and f is zero, then the number represented is +∞ or −∞ according to whether S is +1 or −1. The decoding is done, stop.
  • If e is 255 and f is not zero, the data represents a NaN (Not a Number), and f contains supplementary information. In typical implementations, if the high bit of f is set, the NaN is a quiet, otherwise it is signaling. The decode is done, stop.
  • If e is zero, let E = −126 and let F = 0.
  • Otherwise, let E = e−127 and let F = 1.

Decode the significand bits: Let F = F + f•2−23.

The number represented is SF • 2E.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文