//int public static int bytes2intHigh(byte[] bytes){ int result = 0; if(bytes.length == 4){ int a = (bytes[3] & 0xff) << 24;//说明二 int b = (bytes[2] & 0xff) << 16; int c = (bytes[1] & 0xff) << 8; int d = (bytes[0] & 0xff); result = a | b | c | d; } return result; }
//double public static double bytes2Double(byte[] arr) { long value = 0; for (int i = 0; i < 8; i++) { value |= ((long) (arr[i] & 0xff)) << (8 * i); } return Double.longBitsToDouble(value); }
//short高低位 public static short byte2int16(byte[] bytes) { return (short) ((bytes[0] << 8) | (bytes[1] & 0xFF)); } public static short byte2int16High(byte[] bytes) { return (short) ((bytes[1] << 8) | (bytes[0] & 0xFF)); }
//byte (byte) (SensorType[0] & 0xFF);
java解析16进制
于 2023-12-11 16:49:31 首次发布