Example usage for org.apache.commons.lang NumberUtils compare

List of usage examples for org.apache.commons.lang NumberUtils compare

Introduction

In this page you can find the example usage for org.apache.commons.lang NumberUtils compare.

Prototype

public static int compare(float lhs, float rhs) 

Source Link

Document

Compares two floats for order.

This method is more comprehensive than the standard Java greater than, less than and equals operators.

  • It returns -1 if the first value is less than the second.

    Usage

    From source file:org.sonar.api.measures.RangeDistributionBuilder.java

    private void changeDoublesToInts() {
        boolean onlyInts = true;
        for (Number bottomLimit : bottomLimits) {
            if (NumberUtils.compare(bottomLimit.intValue(), bottomLimit.doubleValue()) != 0) {
                onlyInts = false;/*from  ww  w .  j  a  v  a2 s .c  o  m*/
            }
        }
        if (onlyInts) {
            for (int i = 0; i < bottomLimits.length; i++) {
                bottomLimits[i] = bottomLimits[i].intValue();
            }
        }
    }
    

    From source file:org.sonar.api.measures.RangeDistributionBuilder.java

    private RangeDistributionBuilder addLimitCount(Number limit, int count) {
        for (Number bottomLimit : bottomLimits) {
            if (NumberUtils.compare(bottomLimit.doubleValue(), limit.doubleValue()) == 0) {
                this.countBag.add(limit, count);
                isEmpty = false;//from  ww w .ja v  a  2 s. co m
                return this;
            }
        }
        isValid = false;
        return this;
    }
    

    From source file:org.sonar.api.measures.RangeDistributionBuilder.java

    private static boolean greaterOrEqualsThan(Number n1, Number n2) {
        return NumberUtils.compare(n1.doubleValue(), n2.doubleValue()) >= 0;
    }