1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
    }
}