NumberUtils: compare(double arg0, double arg1) : NumberUtils « org.apache.commons.math « Java by API






NumberUtils: compare(double arg0, double arg1)

/*
(FIRST > SECOND) >>> 1
(FIRST < SECOND) >>> -1
(FIRST == SECOND) >>> 0

 */
import org.apache.commons.lang.math.NumberUtils;

public class MathUtilsTrial {
  public static void main(String[] args) {
    // Compare two double values
    System.out.println("(FIRST > SECOND) >>> " + NumberUtils.compare(2.11, 1.11));
    System.out.println("(FIRST < SECOND) >>> " + NumberUtils.compare(1.11, 2.11));
    System.out.println("(FIRST == SECOND) >>> " + NumberUtils.compare(1.11, 1.11));

  }
}

           
       








Apache-Common-Lang.zip( 248 k)

Related examples in the same category

1.NumberUtils: createBigDecimal(String arg0)
2.NumberUtils: isDigits(String arg0)
3.NumberUtils: isNumber(String arg0)
4.NumberUtils.max(double[] df)