Example usage for java.lang Float intBitsToFloat

List of usage examples for java.lang Float intBitsToFloat

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static native float intBitsToFloat(int bits);

Source Link

Document

Returns the float value corresponding to a given bit representation.

Usage

From source file:Main.java

public static void main(String[] args) {

    System.out.println(Float.intBitsToFloat(123));
    System.out.println(Float.intBitsToFloat(0x7f800000));
    System.out.println(Float.intBitsToFloat(0xff800000));
}

From source file:Main.java

public static float getFloat(byte[] bytes) {
    return Float.intBitsToFloat(getInt(bytes));
}

From source file:Main.java

public static float getFloat(float data, byte[] packet, int index) {
    return (Float.intBitsToFloat(getInt(packet, index)));
}

From source file:Main.java

static public float regAsFloat(int i) {
    return Float.intBitsToFloat(i);
}

From source file:Main.java

public static float readFloat(DataInputStream is) throws IOException {
    return Float.intBitsToFloat(readInt(is));
}

From source file:Main.java

public final static float bytesToFloat(byte[] b) {
    int i = 0;/* w  ww .  ja v  a 2s.  co m*/
    i = ((((b[3] & 0xff) << 8 | (b[2] & 0xff)) << 8) | (b[1] & 0xff)) << 8 | (b[0] & 0xff);
    return Float.intBitsToFloat(i);
}

From source file:Main.java

public static float hexToFloat(String s) {
    int intBits = 0;
    float result = 0;
    try {//w ww.j  a  va  2s  .c o m
        intBits = Integer.parseInt(s, 16);
        result = Float.intBitsToFloat(intBits);
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
    return result;

}

From source file:Main.java

public static final float readFloat(InputStream i) throws IOException {
    return Float.intBitsToFloat(readInt(i));
}

From source file:Main.java

public static final float decodeFloat(byte[] bytes, int offset)
/*    */ {//  w  ww .ja  v a2 s.c om
    /* 67 */return Float.intBitsToFloat(decodeInt(bytes, offset));
    /*    */}

From source file:Main.java

/**
 * Returns next bigger float value considering precision of the argument.
 * // w  ww  . java2  s.  c o m
 */
public static float nextUpF(float f) {
    if (Float.isNaN(f) || f == Float.POSITIVE_INFINITY) {
        return f;
    } else {
        f += 0.0f;
        return Float.intBitsToFloat(Float.floatToRawIntBits(f) + ((f >= 0.0f) ? +1 : -1));
    }
}