Example usage for java.lang Float compare

List of usage examples for java.lang Float compare

Introduction

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

Prototype

public static int compare(float f1, float f2) 

Source Link

Document

Compares the two specified float values.

Usage

From source file:com.playtech.portal.platform.common.util.Validator.java

/**
 * Returns <code>true</code> if the floats are equal.
 *
 * @param  float1 the first float//from ww w .j  a va  2s.  com
 * @param  float2 the second float
 * @return <code>true</code> if the floats are equal; <code>false</code>
 *         otherwise
 */
public static boolean equals(float float1, float float2) {
    if (Float.compare(float1, float2) == 0) {
        return true;
    } else {
        return false;
    }
}

From source file:example.RepoContract.java

@Override
public boolean equals(Object o) {
    if (this == o)
        return true;
    if (o == null || getClass() != o.getClass())
        return false;

    RepoContract that = (RepoContract) o;

    if (Float.compare(that.getRepoRate(), getRepoRate()) != 0)
        return false;
    if (Float.compare(that.getStartAmount(), getStartAmount()) != 0)
        return false;
    if (getPar() != that.getPar())
        return false;
    if (!getXref().equals(that.getXref()))
        return false;
    if (!getTid().equals(that.getTid()))
        return false;
    if (!getCusip().equals(that.getCusip()))
        return false;
    if (!getPartID().equals(that.getPartID()))
        return false;
    return getContraID().equals(that.getContraID());

}

From source file:de.dmxcontrol.executor.EntityExecutor.java

public void setValue(float value, boolean fromReader) {
    int comp = Float.compare(this.value, value);
    boolean isEqual = 0 == comp;
    this.value = value;
    if (!isEqual && fromReader) {
        for (ValueChangedListener listener : ValueChangedListeners) {
            listener.onValueChanged(value);
        }//from  w ww .  ja  va2s.co m
        return;
    } else if (!isEqual && !fromReader) {
        Send();
    }
}

From source file:org.diorite.material.ToolData.java

@Override
public boolean equals(final Object o) {
    if (this == o) {
        return true;
    }/*from w w  w.  j  a v a2  s  . co  m*/
    if (!(o instanceof ToolData)) {
        return false;
    }

    final ToolData toolData = (ToolData) o;

    return (Float.compare(toolData.damage, this.damage) == 0)
            && (Float.compare(toolData.attackSpeed, this.attackSpeed) == 0)
            && this.toolMaterial.equals(toolData.toolMaterial) && this.toolType.equals(toolData.toolType);
}

From source file:org.encuestame.utils.json.HomeBean.java

/**
 * Compare home Bean items./*from  w  ww . j ava 2 s  .c o m*/
 */
public int compareTo(Object o) {
    HomeBean home = (HomeBean) o;
    //log.debug("Home Bean Value: " + home.getRelevance());
    //log.debug("This home bean Value: " + this.getRelevance());
    int CompareToValue = Float.compare(home.getRelevance() == null ? 0 : home.getRelevance(),
            this.getRelevance() == null ? 0 : this.getRelevance());
    if (CompareToValue == 0) {
        return this.getCreateDate().compareTo(home.getCreateDate());
    } else {
        //log.debug(" Result Home Bean compare: " + CompareToValue);
        return CompareToValue;
    }
}

From source file:org.wso2.carbon.databridge.core.Utils.DataBridgeUtils.java

public static boolean compare(Object eventAttr1, Object eventAttr2, AttributeType attributeType)
        throws IOException {
    switch (attributeType) {
    case BOOL: {/*w w  w  .  j av a  2  s .  c o m*/
        if (eventAttr1 != eventAttr2) {
            return false;
        }
        break;
    }
    case INT: {

        Integer tempVal1 = (eventAttr1 instanceof Integer) ? (Integer) eventAttr1
                : ((Double) eventAttr1).intValue();
        Integer tempVal2 = (eventAttr2 instanceof Integer) ? (Integer) eventAttr2
                : ((Double) eventAttr2).intValue();

        if (!tempVal1.equals(tempVal2)) {
            return false;
        }
        break;
    }
    case DOUBLE: {
        if (Double.compare((Double) eventAttr1, (Double) eventAttr2) != 0) {
            return false;
        }
        break;
    }
    case FLOAT: {
        if (Float.compare(((Double) eventAttr1).floatValue(), ((Double) eventAttr2).floatValue()) != 0) {
            return false;
        }
        break;
    }
    case LONG: {
        if (eventAttr1 != eventAttr2) {
            return false;
        }
        break;
    }
    case STRING: {
        return eventAttr1.equals(eventAttr2);
    }
    }
    return true;
}

From source file:com.graphaware.reco.generic.result.Score.java

/**
 * {@inheritDoc}
 */
@Override
public int compareTo(Score o) {
    return Float.compare(getTotalScore(), o.getTotalScore());
}

From source file:di.uniba.it.tee2.search.SearchResult.java

@Override
public int compareTo(SearchResult o) {
    return Float.compare(o.score, score);
}

From source file:org.encuestame.utils.web.ProfileRatedTopBean.java

public int compareTo(Object o) {
    ProfileRatedTopBean profile = (ProfileRatedTopBean) o;
    int CompareToValue = Float.compare(profile.getTopValue() == null ? 0 : profile.getTopValue(),
            this.getTopValue() == null ? 0 : this.getTopValue());
    /*  if (CompareToValue == 0) {
    return this.getCreateDate().compareTo(home.getCreateDate());
      } else {/*  w  w  w . j  av a2s . com*/
    log.debug(" Result Home Bean compare: " + CompareToValue);
    return CompareToValue;
      }*/
    return CompareToValue;
}

From source file:org.apache.hadoop.hive.ql.udf.UDFBetween.java

public BooleanWritable evaluate(FloatWritable a, FloatWritable b, FloatWritable c) {
    if (a == null || b == null || c == null) {
        return new BooleanWritable(false);
    }//from  w  w  w. j av  a2s .  com

    float aa = a.get();
    float bb = b.get();
    float cc = c.get();
    int tmp_a = Float.compare(aa, bb);
    int tmp_b = Float.compare(aa, cc);

    if (tmp_a >= 0 && tmp_b <= 0) {
        return new BooleanWritable(true);
    } else {
        return new BooleanWritable(false);
    }
}