Java Float Number Create toFloat(byte[] bytes)

Here you can find the source of toFloat(byte[] bytes)

Description

to Float

License

Open Source License

Declaration

public static float toFloat(byte[] bytes) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Shuichi Miura.//  w  w w.  j  a  v  a 2 s  . co  m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Shuichi Miura - initial API and implementation
 ******************************************************************************/

public class Main {
    public static float toFloat(byte[] bytes) {

        int intValue = toInt(bytes);
        return Float.intBitsToFloat(intValue);
    }

    public static int toInt(byte[] bytes) {

        return (bytes[3] & 0xff) + ((bytes[2] & 0xff) << 8) + ((bytes[1] & 0xff) << 16) + ((bytes[0] & 0xff) << 24);
    }
}

Related

  1. toFloat(byte[] b)
  2. toFloat(byte[] b)
  3. toFloat(byte[] b, int off, boolean bigEndian)
  4. toFloat(byte[] byteArray)
  5. toFloat(byte[] bytes)
  6. toFloat(byte[] bytes)
  7. toFloat(byte[] bytes)
  8. toFloat(byte[] bytes, int index)
  9. toFloat(byte[] bytes, int offset)