从几个十进制数绘制了一个十六进制数 [英] Drawing up a hexadecimal number from several decimal numbers

查看:125
本文介绍了从几个十进制数绘制了一个十六进制数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个vector容器。有许多从0到255的数据字节是顶部(容器)。第四天开始尾数和它可能由几个数字,例如。尾数由< 120,111,200>。也就是说,它是机器的数量:其中; 0x78,0x6F,0xC8>。总回合尾数: 0x786FC8

  

我可以转换,因为该方法的:

     
      
  1. 设置的120号,111,200为十六进制。(0x78,0x6F,0xC8)
  2.   
  3. 把数字一致。(78,6FC8)
  4.   
  5. 折行了。(786FC8)
  6.   
  7. 将返回一个整数类型。 0x786FC8
  8.   

问:你有什么更快,不附带任何条件做任何

解决方案

这听起来像你想< 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:

  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?

解决方案

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

这篇关于从几个十进制数绘制了一个十六进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆