Example usage for java.lang Float floatToIntBits

List of usage examples for java.lang Float floatToIntBits

Introduction

In this page you can find the example usage for java.lang Float floatToIntBits.

Prototype

@HotSpotIntrinsicCandidate
public static int floatToIntBits(float value) 

Source Link

Document

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout.

Usage

From source file:Main.java

public static byte[] encodeFloat(float payload, byte[] data, int offset) {
    /* 31 */return encodeInt(Float.floatToIntBits(payload), data, offset);
    /*    */}

From source file:Main.java

public static byte[] toLH(float f) {
    return toLH(Float.floatToIntBits(f));
}

From source file:Main.java

public static void writeFloat(OutputStream out, float f, boolean big_endian) throws IOException {
    int bits = Float.floatToIntBits(f);
    writeInt(out, bits, big_endian);/*w w w .  j  av  a  2  s  . c o  m*/
}

From source file:Main.java

/**
 * Util method that converts a float into a byte array using a buffer.
 *
 * @param buffer The buffer to put the converted float
 * @param pos    The position to start putting the converted float
 * @param input  The float to convert/*from  w ww  .j a va 2 s  .  co m*/
 */
public static void putFloatToBytes(byte[] buffer, int pos, float input) {
    /* Get the integer representation in order bitwise operations */
    int value = Float.floatToIntBits(input);

    /* Convert the float into array of bytes */
    for (int i = pos; i < pos + FLOAT_SIZE; i++) {
        buffer[i] = (byte) (value >> (((FLOAT_SIZE - 1) - (i - pos)) * BITS_IN_BYTE));
    }
}

From source file:Main.java

private static int writeFloat(byte[] buffer, int offset, float value) {
    return writeInt(buffer, offset, Float.floatToIntBits(value));
}

From source file:Main.java

public static int floatToIntBits(float value) {
    return Float.floatToIntBits(value);
}

From source file:Main.java

/**
 * Converts a float value to a byte[4] binary float value.
 *
 * @param f the float to be converted.//from  w  w w .ja v a 2 s . com
 * @return a byte[4] containing the float value.
 */
public static final byte[] floatToRegisters(float f) {
    return intToRegisters(Float.floatToIntBits(f));
}

From source file:Main.java

/**
 * Converts a "float" value between endian systems.
 * @param value value to convert// ww  w . j  a v  a2s  . c  o  m
 * @return the converted value
 */
public static float swapFloat(float value) {
    return Float.intBitsToFloat(swapInteger(Float.floatToIntBits(value)));
}

From source file:Main.java

/**
 * Writes a "float" value to a byte array at a given offset. The value is
 * converted to the opposed endian system while writing.
 * @param data target byte array/* w  w  w  . j a  v a  2 s  .  c o m*/
 * @param offset starting offset in the byte array
 * @param value value to write
 */
public static void writeSwappedFloat(byte[] data, int offset, float value) {
    writeSwappedInteger(data, offset, Float.floatToIntBits(value));
}

From source file:Main.java

public static byte[] getBytes(float data) {
    int intBits = Float.floatToIntBits(data);
    return getBytes(intBits);
}