Java Float Number Create toFloat(byte[] value)

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

Description

to Float

License

Open Source License

Declaration

public static float toFloat(byte[] value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static float toFloat(byte[] value) {
        int intValue = toInt(value);
        float result = Float.intBitsToFloat(intValue);
        return result;
    }/*from ww w.ja  v a 2s. c o  m*/

    public static int toInt(byte[] value) {
        return toInt(value, 0);
    }

    /**
     * byte[] -> int
     * 
     * @param value
     * @param offset
     * @return
     */
    public static int toInt(byte[] value, int offset) {
        int result = 0;
        result = result | (value[offset + 3] & 0xff);
        result = result | ((((int) value[offset + 2] & 0xff)) << 8);
        result = result | ((((int) value[offset + 1] & 0xff)) << 16);
        result = result | ((((int) value[offset + 0] & 0xff)) << 24);
        return result;
    }
}

Related

  1. toFloat(byte[] bytes, int offset)
  2. toFloat(byte[] data)
  3. toFloat(byte[] data)
  4. toFloat(byte[] data, int offset)
  5. toFloat(byte[] si, boolean isReverseOrder)
  6. toFloat(byte[][] a)
  7. toFloat(double in1)
  8. toFloat(double[] a)
  9. toFloat(double[] a)