in src/main/java/com/ql/util/express/OperatorOfNumber.java [137:177]
public static int compareNumber(Number op1, Number op2) {
int type1 = OperatorOfNumber.getSeq(op1.getClass());
int type2 = OperatorOfNumber.getSeq(op2.getClass());
int type = Math.max(type1, type2);
if (type == 1) {
byte o1 = op1.byteValue();
byte o2 = op2.byteValue();
return Byte.compare(o1, o2);
}
if (type == 2) {
short o1 = op1.shortValue();
short o2 = op2.shortValue();
return Short.compare(o1, o2);
}
if (type == 3) {
int o1 = op1.intValue();
int o2 = op2.intValue();
return Integer.compare(o1, o2);
}
if (type == 4) {
long o1 = op1.longValue();
long o2 = op2.longValue();
return Long.compare(o1, o2);
}
if (type == 5) {
float o1 = op1.floatValue();
float o2 = op2.floatValue();
return Float.compare(o1, o2);
}
if (type == 6) {
double o1 = op1.doubleValue();
double o2 = op2.doubleValue();
return Double.compare(o1, o2);
}
if (type == 7) {
BigDecimal o1 = new BigDecimal(op1.toString());
BigDecimal o2 = new BigDecimal(op2.toString());
return o1.compareTo(o2);
}
throw new RuntimeException("比较操作错误:op1=" + op1 + ",op2=" + op2);
}