Android Byte Array to Float Convert getFloat(int offset, byte[] fromBytes)

Here you can find the source of getFloat(int offset, byte[] fromBytes)

Description

get Float

License

Open Source License

Declaration

public static float getFloat(int offset, byte[] fromBytes) 

Method Source Code

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

public class Main {
    public static float getFloat(int offset, byte[] fromBytes) {
        final float toFloat;

        final int fromInt = getInt(offset, fromBytes);
        toFloat = Float.intBitsToFloat(fromInt);

        return toFloat;
    }// w w w. j a va2s . co  m

    public static int getInt(int offset, byte[] fromBytes) {
        final int toInt;

        toInt = ((0xff & fromBytes[offset + 0]) << 24)
                | ((0xff & fromBytes[offset + 1]) << 16)
                | ((0xff & fromBytes[offset + 2]) << 8)
                | ((0xff & fromBytes[offset + 3]) << 0);

        return toInt;
    }
}

Related

  1. bytesToFloat(byte[] bytes)
  2. bytesToFloat(byte[] bytes, int start)
  3. getFloat(byte[] b, int index)
  4. getFloat(byte[] buf, boolean bigEndian)
  5. getFloat(byte[] bytes)
  6. getFloats(float[] toFloats, byte[] fromBytes)
  7. getFloats(float[] toFloats, int offset, byte[] fromBytes)
  8. toFloat(byte[] b, int pos)
  9. toFloatEx(byte[] b, int pos)