package com.hdl.sdk.hdl_core.Util.TransformUtil;
|
|
import java.nio.ByteBuffer;
|
|
public class DataConverseUtil {
|
public static float byte2Float(byte[] bytes) {
|
if (bytes.length != 4) {
|
return 0;
|
}
|
byte b[] = bytes;
|
ByteBuffer buf = ByteBuffer.allocateDirect(4);
|
// buf=buf.order(ByteOrder.LITTLE_ENDIAN);小端用这行代码,默认大端转换
|
buf.put(b);
|
buf.rewind();
|
float f2 = buf.getFloat();
|
return f2;
|
}
|
}
|