Java Float Number Convert to convertFloatFromBytes(byte[] byteArray)

Here you can find the source of convertFloatFromBytes(byte[] byteArray)

Description

convert Float From Bytes

License

Open Source License

Declaration

public static float convertFloatFromBytes(byte[] byteArray) 

Method Source Code

//package com.java2s;

public class Main {
    public static float convertFloatFromBytes(byte[] byteArray) {
        return convertFloatFromBytes(byteArray, 0);
    }//  w  w  w  .j a va2 s.c o  m

    public static float convertFloatFromBytes(byte[] byteArray, int offset) {
        // Convert it to an int
        int number = convertIntFromBytes(byteArray, offset);
        return Float.intBitsToFloat(number);
    }

    public static int convertIntFromBytes(byte[] byteArray) {
        return convertIntFromBytes(byteArray, 0);
    }

    public static int convertIntFromBytes(byte[] byteArray, int offset) {
        // Convert it to an int
        int number = ((byteArray[offset] & 0xFF) << 24)
                + ((byteArray[offset + 1] & 0xFF) << 16)
                + ((byteArray[offset + 2] & 0xFF) << 8)
                + (byteArray[offset + 3] & 0xFF);
        return number;
    }
}

Related

  1. convertFloat(String str, float defaults)
  2. convertFloatArray(float[] arr)
  3. convertFloatArrayToString(float[] value, String separator)
  4. convertFloatBitsToHFloat(final int floatBits)
  5. convertFloatDouble(float[] in)
  6. convertFloatFromStream(byte[] stream, int intStart, int decStart, int intNumbers, int decNumbers)
  7. convertFloatMatrixToDoubles(float[][] input, int dimRows, int dimColoumns)
  8. convertFloatsToFixed(float[] values)
  9. convertFloatToHex(float floatValue)