From 606d7388589829e6a7108a48898d4e4126312d73 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期三, 01 十一月 2023 16:38:11 +0800 Subject: [PATCH] 增加雷达角度引导信息反馈 --- src/main/java/com/ard/utils/other/ByteUtils.java | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/ard/utils/other/ByteUtils.java b/src/main/java/com/ard/utils/other/ByteUtils.java index b82cd85..f89e0e9 100644 --- a/src/main/java/com/ard/utils/other/ByteUtils.java +++ b/src/main/java/com/ard/utils/other/ByteUtils.java @@ -1,5 +1,6 @@ package com.ard.utils.other; +import javax.xml.bind.DatatypeConverter; import java.io.ByteArrayOutputStream; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; @@ -14,6 +15,14 @@ * @Version: 1.0 **/ public class ByteUtils { + + /** + * 鎵撳嵃鍗佸叚杩涘埗浜岃繘鍒� + */ + public static String printHexBinary(byte[] bytes) { + return DatatypeConverter.printHexBinary(bytes); + } + /** * byte鏁扮粍杞腑鏂囧瓧绗︿覆 */ @@ -116,6 +125,28 @@ } /** + * double杞琤yte鏁扮粍 + */ + public static byte[] doubleToBytes(double d) { + long value = Double.doubleToRawLongBits(d); + byte[] byteRet = new byte[8]; + for (int i = 0; i < 8; i++) { + byteRet[i] = (byte) ((value >> 8 * i) & 0xff); + } + return byteRet; + } + /** + * float杞琤yte鏁扮粍 + */ + public static byte[] floatToBytes(float f) { + // 鍒涘缓涓�涓� ByteBuffer锛屽垎閰嶈冻澶熺殑绌洪棿鏉ュ瓨鍌ㄤ竴涓� float 鍊� + ByteBuffer buffer = ByteBuffer.allocate(Float.BYTES); + // 灏� float 鍊煎啓鍏� ByteBuffer + buffer.putFloat(f); + // 鑾峰彇瀛楄妭鏁扮粍 + return buffer.array(); + } + /** * byte鏁扮粍鎷兼帴 */ public static byte[] appendArrays(byte[]... arrays) { -- Gitblit v1.9.3