Java Float to Byte Array floatToBytes(float f)

Here you can find the source of floatToBytes(float f)

Description

float To Bytes

License

Apache License

Declaration

public static byte[] floatToBytes(float f) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] floatToBytes(float f) {
        return intToBytes(Float.floatToIntBits(f));
    }//w  w w  .j  a  v  a2s.c o  m

    public static byte[] intToBytes(int i) {
        byte[] b = new byte[4];
        b[0] = (byte) (i >>> 24);
        b[1] = (byte) (i >>> 16);
        b[2] = (byte) (i >>> 8);
        b[3] = (byte) i;
        return b;
    }
}

Related

  1. floatToByteArray(float number)
  2. floatToByteArray(float source)
  3. floatToByteArray(float value)
  4. floatToByteArrayBE(float data)
  5. floatToBytes(final float f)
  6. floatToBytes(float fnum, byte[] bytes, int startIndex)
  7. floatToBytes(float num, byte[] arr, int pos)
  8. floatToBytes(float theFloat)
  9. FloatToBytesLE(final float value)