public class ByteBufferDemo {
public static void main(String[] args) {
System.out.print(getInt((short) -23432) + " ");
}
public static int getInt(short tmp) {//大端模式存放,高位放低字节,低位放高字节
short number = tmp;
byte[] temp = new byte[2];
temp[0] = (byte) (number >> 8);
temp[1] = (byte) (number); //short转字节数组
short temp0 = temp[0];
short temp1 = temp[1];
short tempRes = (short) (temp0 << 8);
short result = (short) (tempRes + (temp1 > 0 ? temp1 : temp1 & 0x00ff));//字节数组转short
return result;
}
}
免责声明
本站部分资源来源于互联网 如有侵权 请联系站长删除
龙哥网是优质的互联网科技创业资源_行业项目分享_网络知识引流变现方法的平台为广大网友提供学习互联网相关知识_内容变现的方法。