final TypeRegistry typeRegistry = context.getTypeRegistry();
if (value1 == null || value2 == null)
{
// If this happens, then one of the implementations has messed up.
throw new EvaluationException(LibFormulaErrorValue.ERROR_UNEXPECTED_VALUE);
}
final Object raw1 = value1.getValue();
final Object raw2 = value2.getValue();
if (raw1 == null || raw2 == null)
{
throw new EvaluationException (LibFormulaErrorValue.ERROR_NA_VALUE);
}
final Number number1 = TypeRegistryUtility.convertToNumber(typeRegistry, value1.getType(), raw1, ZERO);
final Number number2 = TypeRegistryUtility.convertToNumber(typeRegistry, value2.getType(), raw2, ZERO);
return new TypeValuePair(NumberType.GENERIC_NUMBER, evaluate(number1, number2));