Here you can find the source of bytesToFloat(byte[] bytes, int startIndex)
Parameter | Description |
---|---|
bytes | the byte array |
startIndex | the starting index of the place the int is stored |
public static float bytesToFloat(byte[] bytes, int startIndex)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w.j a v a 2s. c o m * Given a byte array, restore it as an int * * @param bytes * the byte array * @param startIndex * the starting index of the place the int is stored */ public static float bytesToFloat(byte[] bytes, int startIndex) { return (Float.intBitsToFloat(bytesToInt(bytes, startIndex))); } /** * Given a byte array, restore it as an int * * @param bytes * the byte array * @param startIndex * the starting index of the place the int is stored */ public static int bytesToInt(byte[] bytes, int startIndex) { return (((int) bytes[startIndex] & 0xff) | (((int) bytes[startIndex + 1] & 0xff) << 8) | (((int) bytes[startIndex + 2] & 0xff) << 16) | (((int) bytes[startIndex + 3] & 0xff) << 24)); } }