Java Byte Array to Float bytesToFloat(byte[] b)

Here you can find the source of bytesToFloat(byte[] b)

Description

bytes To Float

License

Open Source License

Declaration

public static float bytesToFloat(byte[] b) 

Method Source Code

//package com.java2s;
/**/*from w ww .  j a  v  a 2s  . com*/
 * Copyright @ 2007, ST Electronics Info-comm Systems PTE. LTD All rights
 * reserved.
 *
 * This software is confidential and proprietary property of ST Electronics
 * Info-comm Systems PTE. LTD. The user shall not disclose the contents of this
 * software and shall only use it in accordance with the terms and conditions
 * stated in the contract or licence agreement with ST Electronics Info-comm
 * Systems PTE. LTD.
 *
 * @author Jerry
 * @version 1.0
 *
 */

public class Main {

    public static float bytesToFloat(byte[] b) {
        return Float.intBitsToFloat(bytesToInt(b));
    }

    public static int bytesToInt(byte[] b) {
        int i = (b[0] << 24) & 0xFF000000;
        i |= (b[1] << 16) & 0xFF0000;
        i |= (b[2] << 8) & 0xFF00;
        i |= b[3] & 0xFF;
        return i;
    }
}

Related

  1. byteArrayToFloatBE(byte[] data)
  2. bytes2float(byte[] b)
  3. bytes2Float(byte[] b, float defaultValue)
  4. bytes2float(byte[] bytes)
  5. bytes2float(byte[] bytes)
  6. bytesToFloat(byte[] b, int offset)
  7. bytesToFloat(byte[] bytes)
  8. bytesToFloat(byte[] bytes, int beg)
  9. bytesToFloat(byte[] bytes, int startIndex)