Java Byte Array to Float bytesToFloat(byte[] bytes, int beg)

Here you can find the source of bytesToFloat(byte[] bytes, int beg)

Description

Convert a byte array to float.

License

Open Source License

Parameter

Parameter Description
bytes The bytes array
beg The beginning index of the float value

Return

The float value

Declaration

private static float bytesToFloat(byte[] bytes, int beg) 

Method Source Code

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

public class Main {
    /**// w ww  . ja va  2 s .co  m
     * Convert a byte array to float. The byte array
     * is returned by ShopPositioningServer.
     *
     * @param bytes The bytes array
     * @param beg The beginning index of the float value
     * @return The float value
     */
    private static float bytesToFloat(byte[] bytes, int beg) {
        int bits = 0;
        bits |= (bytes[beg + 3] & 0xff);
        bits |= (bytes[beg + 2] & 0xff) << 8;
        bits |= (bytes[beg + 1] & 0xff) << 16;
        bits |= (bytes[beg] & 0xff) << 24;
        return Float.intBitsToFloat(bits);
    }
}

Related

  1. bytes2float(byte[] bytes)
  2. bytes2float(byte[] bytes)
  3. bytesToFloat(byte[] b)
  4. bytesToFloat(byte[] b, int offset)
  5. bytesToFloat(byte[] bytes)
  6. bytesToFloat(byte[] bytes, int startIndex)
  7. byteToFloat(byte[] b)
  8. byteToFloat(byte[] b)