二进制字符串转十进制值,公式?
使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(2)
即
68*256^3 + 67*256^2 + 66*256 + 70
。看看您提到的不正确的公式,我建议您阅读一些有关位值表示法的内容。还要考虑一下,如果您有一种可以存储
k
个不同值的变量(一个字节可以存储 256 个不同的值,通常用0..255
之间的整数来标识),该怎么办? ,那么其中 2 个变量可以存储k*k = k^2
不同的值,更一般地,其中n
可以存储k^n
总共不同的值。It is
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 through0..255
), then 2 of these variables can storek*k = k^2
different values, more generally,n
of them can storek^n
different values in total.(((68*256)+67)*256+66)*256+70=1145258566
( ( ( 68 * 256 ) + 67 ) * 256 + 66 ) * 256 + 70 = 1145258566