Java Utililty Methods Byte Array to Float

List of utility methods to do Byte Array to Float

Description

The list of methods to do Byte Array to Float are organized into topic(s).

Method

floatbytes2float(byte[] b)
bytesfloat
return bytes2float(b, 0);
floatbytes2Float(byte[] b, float defaultValue)
bytes Float
if (b == null || b.length < 4) {
    return defaultValue;
} else {
    return bytes2Float(b);
floatbytes2float(byte[] bytes)
bytesfloat
return Float.intBitsToFloat(bytes2int(bytes));
floatbytes2float(byte[] bytes)
bytesfloat
return Float.intBitsToFloat(bytes2int(bytes));
floatbytesToFloat(byte[] b)
bytes To Float
return Float.intBitsToFloat(bytesToInt(b));
floatbytesToFloat(byte[] b, int offset)
bytes To Float
int l;
l = b[offset + 0];
l &= 0xff;
l |= ((long) b[offset + 1] << 8);
l &= 0xffff;
l |= ((long) b[offset + 2] << 16);
l &= 0xffffff;
l |= ((long) b[offset + 3] << 24);
...
floatbytesToFloat(byte[] bytes)
bytes To Float
int l;
l = bytes[0];
l &= 0xff;
l |= ((long) bytes[1] << 8);
l &= 0xffff;
l |= ((long) bytes[2] << 16);
l &= 0xffffff;
l |= ((long) bytes[3] << 24);
...
floatbytesToFloat(byte[] bytes, int beg)
Convert a byte array to float.
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);
floatbytesToFloat(byte[] bytes, int startIndex)
Given a byte array, restore it as an int
return (Float.intBitsToFloat(bytesToInt(bytes, startIndex)));
floatbyteToFloat(byte[] b)
byte To Float
return Float.intBitsToFloat(byteToInt(b));