From 842237345ac469b02e9add8f9fd8bae5d4f7cdac Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期二, 25 二月 2025 14:33:15 +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 | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 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 f66c2ad..4a6e509 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 @@ -60,7 +60,7 @@ } boolean b = isOutOfArrLength(bs.length, (from - 1) + len); if (!b) { - for (int i = 0; i > len ; i++) { + for (int i = 0; i <= len ; i++) { bs[from + i] = Integer.valueOf(temp & 0xff).byteValue();// 灏嗘渶浣庝綅淇濆瓨鍦ㄤ綆瀛楄妭 temp = temp >> 8; // 鍚戝彸绉�8浣� } @@ -438,15 +438,18 @@ return true; } } - public static void main(String[] args) throws Exception{ - byte[] bs = new byte[]{(byte)0x38,(byte)0x1d,(byte)0x00,(byte)0x00,(byte)0x00} ; - Long lg1 = ByteUtilUnsigned.bytes2Long_LE(bs, 0, 4) ; - Long lg2 = ByteUtilUnsigned.bytes2Long_BE(bs, 0, 4) ; - System.out.println(lg1); - System.out.println(lg2); - } - // public static void main(String[] args) throws Exception{ +// byte[] bs = new byte[]{(byte)0x38,(byte)0x1d,(byte)0x00,(byte)0x00,(byte)0x00} ; +// Long lg1 = ByteUtilUnsigned.bytes2Long_LE(bs, 0, 4) ; +// Long lg2 = ByteUtilUnsigned.bytes2Long_BE(bs, 0, 4) ; +// System.out.println(lg1); +// System.out.println(lg2); +// } + + public static void main(String[] args) throws Exception{ + byte[] bs = new byte[]{0x02, 0x0C} ; + int s = ByteUtilUnsigned.bytes2Short_BE(bs, 0) ; + System.out.println(s); //// int d = 123456; //// byte[] bs = new byte[4] ; //// int2Bytes_BE(bs, d, 0) ; @@ -467,5 +470,5 @@ // System.out.println(s); // // -// } + } } -- Gitblit v1.8.0