我如何能结合4个字节为32位无符号整数? [英] How can I combine 4 bytes into a 32 bit unsigned integer?
本文介绍了我如何能结合4个字节为32位无符号整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想4个字节转换成32位无符号整数。
I'm trying to convert 4 bytes into a 32 bit unsigned integer.
我想,也许是这样的:
UInt32 combined = (UInt32)((map[i] << 32) | (map[i+1] << 24) | (map[i+2] << 16) | (map[i+3] << 8));
但是,这似乎并不奏效。我缺少什么?
But this doesn't seem to be working. What am I missing?
推荐答案
您班次都是关闭的8移了24,16,8和0。
Your shifts are all off by 8. Shift by 24, 16, 8, and 0.
这篇关于我如何能结合4个字节为32位无符号整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文