From 6b0887d87b99c7d79ae14ed1000b257cc9053524 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 08 五月 2024 13:55:06 +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/ByteUtilUnsigned.java | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java
index 8635450..eda37b9 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtilUnsigned.java
@@ -131,6 +131,42 @@
throw new Exception("byte2Int鏃舵暟缁勮秺鐣�");
}
}
+
+ /**
+ * 灏忕妯″紡銆婃暟鎹綆浣嶅湪鏁扮粍浣庡瓧鑺傘��
+ * 涓庢柟娉昩ytes2Int绠楁硶涓�鏍凤紝鍙槸鎶婇『搴忓弽杩囨潵
+ * @param bs 瀛楄妭鏁扮粍
+ * @param from 瀛楄妭鏁扮粍璧峰浣嶇疆
+ * @param has3Byte 鏄惁鍖呭惈鏁版嵁涓嬫爣涓�3鐨勫瓧鑺傦紝濡傛灉涓嶅寘鍚疄闄呭鐞嗙殑鏄�3瀛楄妭鐨勬暣鏁�
+ * @return
+ */
+ public static long bytes2Int_LE(byte[] bs, int from, boolean has3Byte) throws Exception {
+ boolean b = isOutOfArrLength(bs.length, (from - 1) + 4);
+ if (!b) {
+ long s = 0;
+ long s0 = bs[from + 0] & 0xFF ;// 鏁版嵁鐨勬渶浣庝綅鍦ㄤ綆瀛楄妭
+ long s1 = bs[from + 1] & 0xFF ;
+ long s2 = bs[from + 2] & 0xFF ;
+ long s3 = 0L ;
+ if(!has3Byte){
+ s3 = bs[from + 3] & 0xFF ;
+ }
+
+
+ // S0涓嶅彉
+ s1 <<= 8;
+ s2 <<= 16;
+ s3 <<= 24;
+ s = s0 | s1 | s2 | s3;
+ if(s < 0){
+ //s = Integer.MAX_VALUE -s ;
+ s = Integer.MAX_VALUE * 2 + 1 + s + 1 ;
+ }
+ return s;
+ } else {
+ throw new Exception("byte2Int鏃舵暟缁勮秺鐣�");
+ }
+ }
/**
* 澶х妯″紡銆婃暟鎹綆浣嶅湪鏁扮粍楂樺瓧鑺傘��
* 鏃犵鍙穝hort绫诲瀷杞崲鎴�2浣峛yte鏁扮粍
--
Gitblit v1.8.0