List of utility methods to do Byte Array to Float
float | arr2float(byte[] b) arrfloat int i = 0; int len = 4; int cnt = 0; byte[] tmp = new byte[len]; for (i = 0; i < len; i++) { tmp[cnt] = b[i]; cnt++; int accum = 0; i = 0; for (int shiftBy = 0; shiftBy < 32; shiftBy += 8) { accum |= ((long) (tmp[i] & 0xff)) << shiftBy; i++; return Float.intBitsToFloat(accum); |
float | byteArrayToFloat(byte value[]) byte Array To Float float temp = 0; temp += (((int) value[0]) & 0xFF) << 24; temp += (((int) value[1]) & 0xFF) << 16; temp += (((int) value[2]) & 0xFF) << 8; temp += (((int) value[3]) & 0xFF); return temp; |
float | byteArrayToFloat(byte[] array) byte Array To Float byte[] tmp = new byte[4]; System.arraycopy(array, 0, tmp, 0, 4); int accum = 0; int i = 0; for (int shiftBy = 0; shiftBy < 32; shiftBy += 8) { accum |= ((long) (tmp[i++] & 0xff)) << shiftBy; return Float.intBitsToFloat(accum); ... |
float | byteArrayToFloat(byte[] b) byte Array To Float int l = byteArrayToInt(b); return Float.intBitsToFloat(l); |
float | byteArrayToFloat(byte[] byteArray) byte Array To Float return Float.intBitsToFloat(byteArrayToInt(byteArray));
|
float | byteArrayToFloat(byte[] byteArray) byte array to float float number = 0f; if (byteArray != null && byteArray.length == 4) { int intBits = 0; intBits = byteArray[0]; intBits &= 0xff; intBits |= ((int) byteArray[1] << 8); intBits &= 0xffff; intBits |= ((int) byteArray[2] << 16); ... |
Float | byteArrayToFloat(byte[] bytes) byte Array To Float int bits = byteArrayToInt(bytes); return Float.intBitsToFloat(bits); |
float | byteArrayToFloat(byte[] bytes, int size, int fpBits) Convert a byte array to its floating point representation. return byteArrayToLong(bytes, size) / (float) (1 << fpBits); |
float[] | byteArrayToFloatArray(byte[] bytes) byte Array To Float Array float[] floats = new float[bytes.length / 4]; for (int i = 0; i < floats.length; ++i) floats[i] = readFloatFromBytes(bytes, i * 4); return floats; |
float | byteArrayToFloatBE(byte[] data) byte Array To Float BE if (data == null || data.length != 4) return 0x0; return Float.intBitsToFloat(byteArrayToIntBE(data)); |