从几个十进制数绘制了一个十六进制数 [英] Drawing up a hexadecimal number from several decimal numbers
问题描述
我有一个vector容器。有许多从0到255的数据字节是顶部(容器)。第四天开始尾数和它可能由几个数字,例如。尾数由< 120,111,200>。也就是说,它是机器的数量:其中; 0x78,0x6F,0xC8>。总回合尾数: 0x786FC8 。
我可以转换,因为该方法的:
- 设置的120号,111,200为十六进制。(0x78,0x6F,0xC8)
- 把数字一致。(78,6FC8)
- 折行了。(786FC8)
- 将返回一个整数类型。 0x786FC8
问:你有什么更快,不附带任何条件做任何
?这听起来像你想< 120 的 111 的 200 的>→ ( 120 的* 256 + 111 的)* 256 + 200
。
I have a vector container. There are a number from 0 to 255. The data bytes are top (of the container). On the fourth day begins mantissa and it may consist of several numbers, for example. Mantissa consists of <120, 111, 200>. That is, it is the number of machine: <0x78, 0x6F, 0xC8>. Total turn mantissa: 0x786FC8.
I can convert because of the method:
- Set the number of 120, 111, 200 in hexadecimal.(0x78, 0x6F, 0xC8)
- Put the numbers in line.("78" "6F" "C8")
- Fold the line.("786FC8")
- Move back to an integer type. 0x786FC8
Q: Is there any way you do it faster and without strings?
It sounds like you want <120, 111, 200> → (120 * 256 + 111) * 256 + 200
.
这篇关于从几个十进制数绘制了一个十六进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!