Open sdementen opened 10 years ago
looking at Exprs.java (org.boris.expr.util)
isn't it a quick win changing simply from...
public static Expr parseValue(String expression) {
Expr result;
try {
result = new ExprInteger(Integer.parseInt(expression));
} catch (Exception e) {
try {
result = new ExprDouble(Double.parseDouble(expression));
} catch (Exception ex) {
result = new ExprString(expression);
}
}
return result;
}
to
public static Expr parseValue(String expression) {
Expr result;
try {
result = new ExprInteger(Integer.parseInt(expression));
} catch (Exception e) {
try {
if(expression.equals("#DIV/0!"))
result=new ExprDouble(Double.Inf);
else if(expression.equals("#NaN"))
result=new ExprDouble(Double.Nan);
else
result = new ExprDouble(Double.parseDouble(expression));
} catch (Exception ex) {
result = new ExprString(expression);
}
}
return result;
}
would that be enough? (I see: in addition one needs to test whether "expression" is NOT of type String...)
Could the NAN and #DIV/0 be converted in standard IEEE 754 float (instead of XL_TYPE_ERR) ? For numerical packages in python/R, this would probably make sense. Moreover, this would allow to keep a single type (even in case of numerical errors) in a XL_TYPE_ARRAY (see related issue).
sebastien