Java Float to Byte floatToByte(float d)

Here you can find the source of floatToByte(float d)

Description

float To Byte

License

Apache License

Declaration

public static byte[] floatToByte(float d) 

Method Source Code

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

public class Main {

    public static byte[] floatToByte(float d) {
        byte[] bytes = new byte[4];
        int l = Float.floatToIntBits(d);
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = Integer.valueOf(l).byteValue();
            l = l >> 8;//from  w  ww  . j  a v  a  2s .  c o  m
        }
        return bytes;
    }
}

Related

  1. floatToByte(Float f)
  2. floatToByte(float f)
  3. floatToByte(float f)