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