private static int getCommonClassCode(Number num1, Number num2) throws TemplateException { int c1 = getClassCode(num1); int c2 = getClassCode(num2); int c = c1 > c2 ? c1 : c2; // If BigInteger is combined with a Float or Double, the result is a // BigDecimal instead of BigInteger in order not to lose the // fractional parts. If Float is combined with Long, the result is a // Double instead of Float to preserve the bigger bit width. switch(c) { case FLOAT: { if ((c1 < c2 ? c1 : c2) == LONG) { return DOUBLE; } break; } case BIGINTEGER: { int min = c1 < c2 ? c1 : c2; if (min == DOUBLE || min == FLOAT) { return BIGDECIMAL; } break; } } return c; }
private static int getCommonClassCode(Number num1, Number num2) throws TemplateException { int c1 = getClassCode(num1); int c2 = getClassCode(num2); int c = c1 > c2 ? c1 : c2; // If BigInteger is combined with a Float or Double, the result is a // BigDecimal instead of BigInteger in order not to lose the // fractional parts. If Float is combined with Long, the result is a // Double instead of Float to preserve the bigger bit width. switch(c) { case FLOAT: { if ((c1 < c2 ? c1 : c2) == LONG) { return DOUBLE; } break; } case BIGINTEGER: { int min = c1 < c2 ? c1 : c2; if (min == DOUBLE || min == FLOAT) { return BIGDECIMAL; } break; } } return c; }
private static int getCommonClassCode(Number num1, Number num2) throws TemplateException { int c1 = getClassCode(num1); int c2 = getClassCode(num2); int c = c1 > c2 ? c1 : c2; // If BigInteger is combined with a Float or Double, the result is a // BigDecimal instead of BigInteger in order not to lose the // fractional parts. If Float is combined with Long, the result is a // Double instead of Float to preserve the bigger bit width. switch(c) { case FLOAT: { if((c1 < c2 ? c1 : c2) == LONG) { return DOUBLE; } break; } case BIGINTEGER: { int min = c1 < c2 ? c1 : c2; if(min == DOUBLE || min == FLOAT) { return BIGDECIMAL; } break; } } return c; }
private static int getCommonClassCode(Number num1, Number num2) throws TemplateException { int c1 = getClassCode(num1); int c2 = getClassCode(num2); int c = c1 > c2 ? c1 : c2; // If BigInteger is combined with a Float or Double, the result is a // BigDecimal instead of BigInteger in order not to lose the // fractional parts. If Float is combined with Long, the result is a // Double instead of Float to preserve the bigger bit width. switch(c) { case FLOAT: { if ((c1 < c2 ? c1 : c2) == LONG) { return DOUBLE; } break; } case BIGINTEGER: { int min = c1 < c2 ? c1 : c2; if (min == DOUBLE || min == FLOAT) { return BIGDECIMAL; } break; } } return c; }