Object v2,
String v1Type,
String v2Type)
{
int type = getNumericType(v1, v2, v1Type, v2Type, true);
ArithmeticOperations ops;
switch ( type )
{
case BIGINT: return bigIntValue(v1).multiply(bigIntValue(v2));
case BIGDEC: return bigDecValue(v1).multiply(bigDecValue(v2));
case FLOAT:
case DOUBLE: return newReal(type, doubleValue(v1) * doubleValue(v2));
case NONNUMERIC:
// if this is modified, please modify the getArithmeticOperations
// in TypeChecker as well
ops = getArithmeticOperations(v1Type);
if (ops != null) {
return ops.multiply(v1, bigDecValue(v2));
}
else {
ops = getArithmeticOperations(v2Type);
if (ops != null) {
return ops.multiply(v2, bigDecValue(v1));
}
}
return newReal(type, doubleValue(v1) * doubleValue(v2));
case CUSTOMNUMERICTYPE:
int t1 = getNumericType(v1), t2 = getNumericType(v2);
ops = getArithmeticOperations(v1Type, v2Type);
if (t1 > t2) {
return ops.multiply(v1, bigDecValue(v2));
}
else if (t2 > t1) {
return ops.multiply(v2, bigDecValue(v1));
}
// otherwise let the default case handle it
default :
return newInteger(type, longValue(v1) * longValue(v2));
}