二进制字符串转十进制值,公式?

发布于 2024-12-18 16:19:22 字数 526 浏览 4 评论 0原文

使用 Mathematica 使用

Binary String: "FBCD"

#1
I: ImportString["FBCD", {"Binary", "Bit"}]
O: {0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, \
    0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0}

#2
I: ImportString["FBCD", {"Binary", "UnsignedInteger32"}]
O: {1145258566}

#3
I: ImportString["FBCD", {"Binary", "Byte"}]
O: {70, 66, 67, 68}

#3 的输出中的字节值 {70, 66, 67, 68} 来获取 #2 的输出中的 int32 值 {1145258566} 的实际数学公式是什么?

(70^4)+(66^3)+(67^2)+68 我知道这是不正确的,如果有的话,请寻找正确的公式。

Using Mathematica

Binary String: "FBCD"

#1
I: ImportString["FBCD", {"Binary", "Bit"}]
O: {0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, \
    0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0}

#2
I: ImportString["FBCD", {"Binary", "UnsignedInteger32"}]
O: {1145258566}

#3
I: ImportString["FBCD", {"Binary", "Byte"}]
O: {70, 66, 67, 68}

What is actual math formula using the byte values {70, 66, 67, 68} in the output of #3 to get the int32 value {1145258566} in the output of #2?

(70^4)+(66^3)+(67^2)+68
I know this isn't correct, looking for the correct formula if there is one.

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

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

发布评论

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

评论(2

‘画卷フ 2024-12-25 16:19:23

FromDigits[Reverse[{70, 66, 67, 68}], 256]

68*256^3 + 67*256^2 + 66*256 + 70

看看您提到的不正确的公式,我建议您阅读一些有关位值表示法的内容。还要考虑一下,如果您有一种可以存储 k 个不同值的变量(一个字节可以存储 256 个不同的值,通常用 0..255 之间的整数来标识),该怎么办? ,那么其中 2 个变量可以存储 k*k = k^2 不同的值,更一般地,其中 n 可以存储 k^n总共不同的值。

It is

FromDigits[Reverse[{70, 66, 67, 68}], 256]

That is, 68*256^3 + 67*256^2 + 66*256 + 70.

Looking at the incorrect formula you mentioned, I suggest reading a bit about place-value notation. Also think about how if you have a kind of variable that can store k different values (one byte can store 256 different values, commonly identified with integers through 0..255), then 2 of these variables can store k*k = k^2 different values, more generally, n of them can store k^n different values in total.

定格我的天空 2024-12-25 16:19:23

(((68*256)+67)*256+66)*256+70=1145258566

( ( ( 68 * 256 ) + 67 ) * 256 + 66 ) * 256 + 70 = 1145258566

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