Here you can find the source of floatToByteArray(float number)
Parameter | Description |
---|---|
number | a parameter |
public static byte[] floatToByteArray(float number)
//package com.java2s; //License from project: Apache License public class Main { /**//from w w w . j ava2s . c o m * float to byte array * * @param number * @return byte[] */ public static byte[] floatToByteArray(float number) { byte[] byteArray = new byte[4]; Integer intBits = Float.floatToIntBits(number); for (int i = 0; i < byteArray.length; i++) { byteArray[i] = new Integer(intBits).byteValue(); intBits = intBits >> 8; } return byteArray; } }