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:com.github.mhendred.face4j.model.Point.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    Point other = (Point) obj;
    if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
        return false;
    if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y))
        return false;
    return true;/*from  w w w. j  a  v a2 s.  c  o m*/
}

From source file:io.fouad.jtb.core.beans.Location.java

@Override
public int hashCode() {
    int result = (longitude != +0.0f ? Float.floatToIntBits(longitude) : 0);
    result = 31 * result + (latitude != +0.0f ? Float.floatToIntBits(latitude) : 0);
    return result;
}

From source file:AtomicFloat.java

private static final int i(final float f) {
    return Float.floatToIntBits(f);
}

From source file:uk.jamierocks.canarybukkit.impl.entity.CanaryLivingEntity.java

public int _INVALID_getHealth() {
    return Float.floatToIntBits(getHandle().getHealth());
}

From source file:com.quartercode.disconnected.sim.Location.java

@Override
public int hashCode() {

    final int prime = 31;
    int result = 1;
    result = prime * result + Float.floatToIntBits(x);
    result = prime * result + Float.floatToIntBits(y);
    return result;
}

From source file:Main.java

/**
 * Converts a <code>float</code> value to a sortable signed <code>int</code>.
 * The value is converted by getting their IEEE 754 floating-point &quot;float format&quot;
 * bit layout and then some bits are swapped, to be able to compare the result as int.
 * By this the precision is not reduced, but the value can easily used as an int.
 * The sort order (including {@link Float#NaN}) is defined by
 * {@link Float#compareTo}; {@code NaN} is greater than positive infinity.
 * @see #sortableIntToFloat//from   ww  w. j a v  a 2 s  .  com
 */
public static int floatToSortableInt(float val) {
    int f = Float.floatToIntBits(val);
    if (f < 0)
        f ^= 0x7fffffff;
    return f;
}

From source file:com.norconex.collector.http.robot.RobotsTxt.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }//ww w.  j  a v  a 2  s  . c o m
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    RobotsTxt other = (RobotsTxt) obj;
    if (Float.floatToIntBits(crawlDelay) != Float.floatToIntBits(other.crawlDelay)) {
        return false;
    }
    if (!Arrays.equals(filters, other.filters)) {
        return false;
    }
    if (!Arrays.equals(sitemapLocations, other.sitemapLocations)) {
        return false;
    }
    return true;
}

From source file:uk.co.modularaudio.mads.base.bandlimitedoscillator.ui.BandLimitedOscillatorMadUiInstance.java

public void sendPulsewidthChange(final float pulsewidth) {
    sendTemporalValueToInstance(BandLimitedOscillatorIOQueueBridge.COMMAND_PULSE_WIDTH,
            (Float.floatToIntBits(pulsewidth)));
}

From source file:org.ambientlight.config.room.entities.climate.DayEntry.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + hour;/* w ww .j a  va  2s. c o  m*/
    result = prime * result + min;
    result = prime * result + Float.floatToIntBits(temp);
    return result;
}

From source file:dk.statsbiblioteket.netark.dvenabler.wrapper.NumericDocValuesWrapper.java

@Override
public long get(int docID) {
    tracker.ping(docID);/* www . j a  v a 2s  .c  om*/
    try {
        IndexableField iField = reader.document(docID, FIELDS).getField(dvConfig.getName());
        if (iField == null) {
            log.warn("No stored value for field '" + dvConfig.getName() + "' in doc " + docID
                    + ". Returning -1");
            // This should have been handled by {@link DVAtomicReader#getDocsWithField}
            return -1;
        }
        Number number = iField.numericValue();
        if (number == null) {
            throw new RuntimeException("No numeric value '" + iField.stringValue() + "' for field '"
                    + dvConfig.getName() + "' in doc " + docID + ". This looks like a non-numeric field!");
        }
        // TODO: Determine correct method to call from field info
        switch (dvConfig.getNumericType()) {
        case LONG:
            return number.longValue();
        case INT:
            return number.intValue();
        case DOUBLE:
            return Double.doubleToLongBits(number.doubleValue());
        case FLOAT:
            return Float.floatToIntBits(number.longValue());
        default:
            throw new IllegalStateException(
                    "Unknown NumericType " + dvConfig.getNumericType() + " for field " + dvConfig.getName());
        }
    } catch (IOException e) {
        throw new RuntimeException("Unable to get field '" + dvConfig.getName() + "' from docID " + docID, e);
    }
}