Android Utililty Methods Float to Byte Array Convert

List of utility methods to do Float to Byte Array Convert

Description

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

Method

byte[]FloatToByte(float f)
Float To Byte
return IntToByte(Float.floatToIntBits(f));
byte[]float2bytesBE(float val, byte[] b, int off)
floatbytes BE
return int2bytesBE(Float.floatToIntBits(val), b, off);
byte[]float2bytesLE(float val, byte[] b, int off)
floatbytes LE
return int2bytesLE(Float.floatToIntBits(val), b, off);
byte[]floatToBytes(float value)
float To Bytes
int iv = (int) value;
byte[] values = intToBytes(iv);
int fv = (int) ((value - iv) * 1000);
if (fv < 0) {
    fv = 0 - fv;
values = append(values, intToBytes(fv));
return values;
...
byte[]floats2bytesBE(float[] val)
floatsbytes BE
if (val == null)
    return null;
byte[] b = new byte[val.length << 2];
for (int i = 0; i < val.length; i++)
    float2bytesBE(val[i], b, i << 2);
return b;
byte[]floats2bytesLE(float[] val)
floatsbytes LE
if (val == null)
    return null;
byte[] b = new byte[val.length << 2];
for (int i = 0; i < val.length; i++)
    float2bytesLE(val[i], b, i << 2);
return b;
byte[]getBytes(float data)
get Bytes
int intBits = Float.floatToIntBits(data);
return getBytes(intBits);