Java Float to floatToRegisters(float f)

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

Description

Converts a float value to a byte[4] binary float value.

License

Open Source License

Parameter

Parameter Description
f the float to be converted.

Return

a byte[4] containing the float value.

Declaration

public static final byte[] floatToRegisters(float f) 

Method Source Code

//package com.java2s;
//License/*from   ww  w.  jav  a 2  s  .  c  o  m*/

public class Main {
    /**
     * Converts a float value to a byte[4] binary float value.
     *
     * @param f the float to be converted.
     * @return a byte[4] containing the float value.
     */
    public static final byte[] floatToRegisters(float f) {
        return intToRegisters(Float.floatToIntBits(f));
    }

    /**
     * Converts an int value to a byte[4] array.
     *
     * @param v the value to be converted.
     * @return a byte[4] containing the value.
     */
    public static final byte[] intToRegisters(int v) {
        byte[] registers = new byte[4];
        registers[0] = (byte) (0xff & (v >> 24));
        registers[1] = (byte) (0xff & (v >> 16));
        registers[2] = (byte) (0xff & (v >> 8));
        registers[3] = (byte) (0xff & v);
        return registers;
    }
}

Related

  1. floatToChar(float[] values)
  2. floatToHalf(float f)
  3. FloatToInt(double x)
  4. floatToIntColor(float value)
  5. floatToPrefixCoded(float val)
  6. floatToS390IntBits(float ieeeFloat)
  7. floatToSemiPrecision(float f, byte abyte0[], int i)
  8. floatToSortableInt(float val)
  9. floatToSortableInt(float value)