Java Float to Byte floatToByte(float f)

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

Description

float To Byte

License

Open Source License

Declaration

public static byte[] floatToByte(float f) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[] floatToByte(float f) {
        return intToByte(Float.floatToIntBits(f));
    }//from  w w  w  . j  av a2s . c  o  m

    public static byte[] intToByte(int number) {
        int temp = number;
        byte[] b = new byte[4];
        for (int i = 0; i < b.length; i++) {
            b[i] = Long.valueOf(temp & 0xff).byteValue();
            temp = temp >> 8;
        }
        return b;
    }
}

Related

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