集册 Java实例教程 将字节数组转换为浮点

将字节数组转换为浮点

欢马劈雪     最近更新时间:2020-01-02 10:19:05

475
将字节数组转换为浮点
/*
n o w    j a v a  . c o m 提 供
*/


//package com.nowjava;


public class Main {



    public static float byteToFloat(byte[] b) {

        int i = 0;

        Float F = new Float(0.0);

        i = ((((b[3] & 0xff) << 8 | (b[2] & 0xff)) << 8) | (b[1] & 0xff)) << 8

                | (b[0] & 0xff);

        return F.intBitsToFloat(i);

    }

}