Android Byte Array to Float Convert getFloats(float[] toFloats, int offset, byte[] fromBytes)

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

Description

get Floats

License

Open Source License

Declaration

public static void getFloats(float[] toFloats, int offset,
            byte[] fromBytes) 

Method Source Code

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

public class Main {
    public static void getFloats(float[] toFloats, byte[] fromBytes) {
        getFloats(toFloats, 0, fromBytes);
    }/*from  w ww.  ja  v  a 2  s .co  m*/

    public static void getFloats(float[] toFloats, int offset,
            byte[] fromBytes) {
        for (int floatInd = 0; floatInd < toFloats.length; ++floatInd) {
            final int fromInt = getInt(offset + floatInd * 4, fromBytes);
            float toFloat = Float.intBitsToFloat(fromInt);
            toFloats[floatInd] = toFloat;
        }
    }

    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. getFloat(byte[] b, int index)
  2. getFloat(byte[] buf, boolean bigEndian)
  3. getFloat(byte[] bytes)
  4. getFloat(int offset, byte[] fromBytes)
  5. getFloats(float[] toFloats, byte[] fromBytes)
  6. toFloat(byte[] b, int pos)
  7. toFloatEx(byte[] b, int pos)