// float. If any of the lhs, rhs, or target result type are float, then any ambiguity
// in the remaining arguments (such as parameters) should be resolved in favor of
// float. Otherwise, if any are decimal, then decimal should be favored. Otherwise,
// the broadest integer type is preferable, even if the target is of a more limited
// integer type -- math has a way of scaling values up AND down.
VoltType operandType = neededType;
if (operandType.isInteger()) {
operandType = VoltType.BIGINT;
}
VoltType leftType = m_left.getValueType();
VoltType rightType = m_right.getValueType();
if (leftType == VoltType.FLOAT || rightType == VoltType.FLOAT) {
operandType = VoltType.FLOAT;
}
else if (operandType != VoltType.FLOAT) {
if (leftType == VoltType.DECIMAL || rightType == VoltType.DECIMAL) {
operandType = VoltType.DECIMAL;
}
}
m_left.refineOperandType(operandType);
m_right.refineOperandType(operandType);
//XXX Not sure how unary minus (and unary plus?) are handled (possibly via an implicit zero left argument?)
VoltType cast_type = VoltTypeUtil.determineImplicitCasting(m_left.getValueType(), m_right.getValueType());
if (cast_type == VoltType.INVALID) {
throw new RuntimeException("ERROR: Invalid output value type for Expression '" + this + "'");
}
m_valueType = cast_type;
m_valueSize = cast_type.getLengthInBytesForFixedTypes();
}