public static int realCompare(float a, float b)
    {
        // these three ifs can only be true if neither value is NaN
        if (a < b) {
            return -1;
        }
        if (a > b) {
            return 1;
        }
        // this check ensure floatCompare(+0, -0) will return 0
        // if we just did floatToIntBits comparison, then they
        // would not compare as equal
        if (a == b) {
            return 0;
        }

        // this ensures that realCompare(NaN, NaN) will return 0
        // floatToIntBits converts all NaNs to the same representation
        int aBits = floatToIntBits(a);
        int bBits = floatToIntBits(b);
        return Integer.compare(aBits, bBits);
    }
@Test
    public void testRealCompare()
    {
        assertEquals(realCompare(0, Float.parseFloat("-0")), 0);
        assertEquals(realCompare(Float.NaN, Float.NaN), 0);
        // 0x7fc01234 is a different representation of NaN
        assertEquals(realCompare(Float.NaN, intBitsToFloat(0x7fc01234)), 0);
    }