From ede8e6c13bd8d12108ecb9ad0f40480ebf44919c Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期四, 27 六月 2024 16:25:40 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java | 67 ++++++++++++++++----------------- 1 files changed, 33 insertions(+), 34 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java index ee7b49d..d981669 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java @@ -310,7 +310,7 @@ long l = 0; long[] ls = new long[len] ; for(int i = 0 ; i < len; i++){ - ls[i] = bs[i] ; + ls[i] = bs[i] & 0xFF ; } for(int i = len-1 ; i >= 0; i--){ ls[(len - 1) - i] <<= 8 * i ; @@ -334,14 +334,14 @@ boolean b = isOutOfArrLength(bs.length, (from - 1) + 8); if (b) { long s = 0; - long s0 = bs[from + 0] ;// 鏈�浣庝綅 - long s1 = bs[from + 1] ; - long s2 = bs[from + 2] ; - long s3 = bs[from + 3] ; - long s4 = bs[from + 4] ; - long s5 = bs[from + 5] ; - long s6 = bs[from + 6] ; - long s7 = bs[from + 7] ; + long s0 = bs[from + 0] & 0xFF ;// 鏈�浣庝綅 + long s1 = bs[from + 1] & 0xFF ; + long s2 = bs[from + 2] & 0xFF ; + long s3 = bs[from + 3] & 0xFF ; + long s4 = bs[from + 4] & 0xFF ; + long s5 = bs[from + 5] & 0xFF ; + long s6 = bs[from + 6] & 0xFF ; + long s7 = bs[from + 7] & 0xFF ; // s7涓嶅彉 s6 <<= 8; @@ -371,7 +371,7 @@ short len = (short)(end - from + 1) ; long[] ls = new long[len] ; for(short i = 0 ; i < len; i++){ - ls[i] = bs[from + i] ; + ls[i] = bs[from + i] & 0xFF ; } for(short i = (short)(len-1) ; i >= 0; i--){ ls[i] <<= 8 * (len - (i + 1)) ; @@ -400,7 +400,7 @@ long l = 0; long[] ls = new long[len] ; for(int i = 0 ; i < len; i++){ - ls[i] = bs[i] ; + ls[i] = bs[i] & 0xFF ; } for(int i = 0 ; i < len; i++){ ls[(len - 1) - i] <<= 8 * i ; @@ -424,14 +424,14 @@ boolean b = isOutOfArrLength(bs.length, (from - 1) + 8); if (b) { long s = 0; - long s0 = bs[from] ;// 鏈�浣庝綅 - long s1 = bs[from + 1] ; - long s2 = bs[from + 2] ; - long s3 = bs[from + 3] ; - long s4 = bs[from + 4] ; - long s5 = bs[from + 5] ; - long s6 = bs[from + 6] ; - long s7 = bs[from + 7] ; + long s0 = bs[from] & 0xFF ;// 鏈�浣庝綅 + long s1 = bs[from + 1] & 0xFF ; + long s2 = bs[from + 2] & 0xFF ; + long s3 = bs[from + 3] & 0xFF ; + long s4 = bs[from + 4] & 0xFF ; + long s5 = bs[from + 5] & 0xFF ; + long s6 = bs[from + 6] & 0xFF ; + long s7 = bs[from + 7] & 0xFF ; // s0涓嶅彉 s1 <<= 8; @@ -462,7 +462,7 @@ short len = (short)(end - from + 1) ; long[] ls = new long[len] ; for(short i = 0 ; i < len; i++){ - ls[i] = bs[from + i] ; + ls[i] = bs[from + i] & 0xFF ; } for(short i = 0 ; i < len; i++){ ls[i] <<= 8 * i ; @@ -531,10 +531,10 @@ boolean b = isOutOfArrLength(bs.length, (from - 1) + 4); if (b) { int s = 0; - int s0 = bs[from + 0] ;// 鏈�浣庝綅 - int s1 = bs[from + 1] ; - int s2 = bs[from + 2] ; - int s3 = bs[from + 3] ; + int s0 = bs[from + 0] & 0xFF ;// 鏈�浣庝綅 + int s1 = bs[from + 1] & 0xFF ; + int s2 = bs[from + 2] & 0xFF ; + int s3 = bs[from + 3] & 0xFF ; // s3涓嶅彉 s2 <<= 8; @@ -558,10 +558,10 @@ boolean b = isOutOfArrLength(bs.length, (from - 1) + 4); if (b) { int s = 0; - int s0 = bs[from + 0] ;// 鏈�浣庝綅 - int s1 = bs[from + 1] ; - int s2 = bs[from + 2] ; - int s3 = bs[from + 3] ; + int s0 = bs[from + 0] & 0xFF ;// 鏈�浣庝綅 + int s1 = bs[from + 1] & 0xFF ; + int s2 = bs[from + 2] & 0xFF ; + int s3 = bs[from + 3] & 0xFF ; // s0涓嶅彉 s1 <<= 8; @@ -654,8 +654,8 @@ boolean b = isOutOfArrLength(bs.length, (from - 1) + 2); if (b) { int s = 0; - int s0 = bs[from + 0] ; - int s1 = bs[from + 1] ; + int s0 = bs[from + 0] & 0xFF ; + int s1 = bs[from + 1] & 0xFF ; // s1涓嶅彉 s0 <<= 8; @@ -677,8 +677,8 @@ boolean b = isOutOfArrLength(bs.length, (from - 1) + 2); if (b) { int s = 0; - int s0 = bs[from + 0] ; - int s1 = bs[from + 1] ; + int s0 = bs[from + 0] & 0xFF ; + int s1 = bs[from + 1] & 0xFF ; // s0涓嶅彉 s1 <<= 8; @@ -1306,8 +1306,7 @@ public static long BCD2Long_LE(byte[] b, int startIndex, int endIndex)throws Exception { String str = ""; str = decodeBCD_LE(b, startIndex, endIndex - startIndex + 1); - long n = Long.parseLong(str); - return n; + return Long.parseLong(str); } /** -- Gitblit v1.8.0