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 void main(String[] args) {

    System.out.println("Value = " + Float.floatToIntBits(5.5f));
}

From source file:Main.java

public static byte[] floatToByte4(float f) {
    int i = Float.floatToIntBits(f);
    return intToByte4(i);
}

From source file:Util.java

static public boolean areEqual(float aThis, float aThat) {
    //System.out.println("float");
    return Float.floatToIntBits(aThis) == Float.floatToIntBits(aThat);
}

From source file:Main.java

static String HF(float f) {
    return Integer.toHexString(Float.floatToIntBits(f));
}

From source file:Main.java

public static byte[] float2bytes(float value) {
    byte[] result = new byte[4];
    int temp = Float.floatToIntBits(value);

    for (int i = 0; i < 4; i++) {
        result[i] = new Integer(temp).byteValue();
        temp = temp >> 8;/*from  w w w  .j a  v  a  2 s  .  c o m*/
    }

    return result;
}

From source file:Main.java

public static void putFloat(byte[] bb, float x, int index) {
    // byte[] b = new byte[4];
    int l = Float.floatToIntBits(x);
    for (int i = 0; i < 4; i++) {
        bb[index + i] = Integer.valueOf(l).byteValue();
        l = l >> 8;/*  w ww .  j  a  v a  2s .c  om*/
    }
}

From source file:Main.java

public static void putFloat(byte[] bb, float x, int index) {
    // byte[] b = new byte[4];
    int l = Float.floatToIntBits(x);
    for (int i = 0; i < 4; i++) {
        bb[index + i] = new Integer(l).byteValue();
        l = l >> 8;//from   www.j a  va  2s .co m
    }
}

From source file:Main.java

public static void putFloat(byte[] bb, float x, int index) {
    int l = Float.floatToIntBits(x);
    for (int i = 0; i < 4; i++) {
        bb[(index + i)] = Integer.valueOf(l).byteValue();
        l >>= 8;/*w  w w  .j  a  v a  2 s.  c  om*/
    }
}

From source file:Main.java

public static void writeFloat(DataOutputStream os, float f) throws IOException {
    writeInt(os, Float.floatToIntBits(f));
}

From source file:Main.java

public static byte[] dataBytesForFloat(float value) {
    // make sure upper 32 bits are zero (if value is negative they'll get filled with ones by promotion to long)
    long floatBits = Float.floatToIntBits(value) & 0xFFFFFFFFL;
    return dataBytesForLong(floatBits, 4);
}