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