Android开发:int类型数据按照高低位,存放到byte类型的数组

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shakdy/article/details/81165210

int类型的数据—>byte类型数组转换

//byte数组"按高位在前,低位在后"的方式存放int类型数据
int src = 123;
int[] dec = new int[4];
dec[0] = (src /256/256/256);
dec[1] = (src /256/256);
dec[2] = (src /256);
dec[3] = (src %256);
//byte数组按"低位在前,高位在后"的方式存放int类型数据
int src = 123;
int[] dec = new int[4];
dec[0] = (src %256);
dec[1] = (src /256);
dec[2] = (src /256/256);
dec[3] = (src /256/256/256);

猜你喜欢

转载自blog.csdn.net/shakdy/article/details/81165210