大端小端排序 补码反码

大端排序

/*
 * byte[]数组转short类型,大端排序
 */
public static short bytes2ShortBig(byte[] bytes, int startIndex) {
    byte high = bytes[startIndex];
    byte low = bytes[startIndex + 1];
    short z = (short) (((high & 0xFF) << 8) | (0xFF & low));
    return z;
}
posted @ 2021-07-14 10:58  一只桔子2233  阅读(141)  评论(0编辑  收藏  举报