Here you can find the source of toBytes(final float val)
Parameter | Description |
---|---|
val | a parameter |
public static byte[] toBytes(final float val)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { private static final int SIZEOF_FLOAT = Float.SIZE / Byte.SIZE; /**//from w w w . j av a2s. c o m * Convert a float value to a byte array * @param val * @return the byte array */ public static byte[] toBytes(final float val) { ByteBuffer bb = ByteBuffer.allocate(SIZEOF_FLOAT); bb.putFloat(val); return bb.array(); } }