Here you can find the source of byteArrayToFloat(byte[] byteArray)
Parameter | Description |
---|---|
byteArray | a parameter |
public static float byteArrayToFloat(byte[] byteArray)
//package com.java2s; //License from project: Apache License public class Main { /**/* ww w. j av a 2s . com*/ * byte array to float * * @param byteArray * @return float */ public static float byteArrayToFloat(byte[] byteArray) { float number = 0f; if (byteArray != null && byteArray.length == 4) { int intBits = 0; intBits = byteArray[0]; intBits &= 0xff; intBits |= ((int) byteArray[1] << 8); intBits &= 0xffff; intBits |= ((int) byteArray[2] << 16); intBits &= 0xffffff; intBits |= ((int) byteArray[3] << 24); number = Float.intBitsToFloat(intBits); } return number; } }