Convert byte array to float - Java Collection Framework

Java examples for Collection Framework:Array Convert

Description

Convert byte array to float

Demo Code


//package com.java2s;

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);/*from   w ww  . j av  a2 s.c  o m*/
        return F.intBitsToFloat(i);
    }
}

Related Tutorials