{
final Type type = value1.getType();
final Object val = value1.getValue();
if (val == null)
{
throw new EvaluationException(LibFormulaErrorValue.ERROR_NA_VALUE);
}
if (type.isFlagSet(Type.NUMERIC_TYPE))
{
final TypeRegistry typeRegistry = context.getTypeRegistry();
// return the same as zero minus value.
final Number number = typeRegistry.convertToNumber(type, val);
if (number == null)
{
throw new EvaluationException
(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}
final BigDecimal value = NumberUtil.getAsBigDecimal(number);
return new TypeValuePair(NumberType.GENERIC_NUMBER, ZERO.subtract(value));
}
if(val instanceof Number)
{
final BigDecimal value = NumberUtil.getAsBigDecimal((Number)val);
if (value == null)
{
throw new EvaluationException
(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}
return new TypeValuePair(type, ZERO.subtract(value));
}
throw new EvaluationException
(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
}