浏览 4420 次
锁定老帖子 主题:Java读取Unsigned Int的程序
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-12-09
unsigned int的范围为0-4294967295
所以int不再适用,我们这里使用long型
程序如下
public static long readUnsignedInt(byte[] bytes) { long b0 = ((long) (bytes[0] & 0xff)); long b1 = ((long) (bytes[1] & 0xff)) << 8; long b2 = ((long) (bytes[2] & 0xff)) << 16; long b3 = ((long) (bytes[3] & 0xff)) << 24; return (long) (b0 | b1 | b2 | b3); }
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |