Drawing up a hexadecimal number from several decimal numbers

為{幸葍}努か 提交于 2019-12-13 08:25:27

问题


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:

  1. Set the number of 120, 111, 200 in hexadecimal.(0x78, 0x6F, 0xC8)
  2. Put the numbers in line.("78" "6F" "C8")
  3. Fold the line.("786FC8")
  4. Move back to an integer type. 0x786FC8

Q: Is there any way you do it faster and without strings?


回答1:


It sounds like you want <120, 111, 200> → (120 * 256 + 111) * 256 + 200.



来源:https://stackoverflow.com/questions/28315623/drawing-up-a-hexadecimal-number-from-several-decimal-numbers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!