1.整数到转换成4个字节 int length=1491449719; message[0] = length & 0xFF; message[1] = (length >> 8) & 0xFF; message[2] = (length >> 16) & 0xFF; message[3] = (length >> 24) & 0xFF; 2.四个字节转换成整数 int len = message[0] | (message[1] << 8) | (message[2] << 16) | (message[3] << 24);
两个字节,情况下
1.整数到转换成2个字节 int year=1980; message[0] = year & 0xFF; message[1] = (year >> 8) & 0xFF; 2.四个字节转换成整数 int len = message[0] | (message[1] << 8);
时间: 2024-10-10 05:07:07