Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IEEE 754 std for #N/A and #DIV/0 instead of XL_TYPE_ERR #19

Open
sdementen opened this issue Nov 16, 2013 · 1 comment
Open

IEEE 754 std for #N/A and #DIV/0 instead of XL_TYPE_ERR #19

sdementen opened this issue Nov 16, 2013 · 1 comment

Comments

@sdementen
Copy link

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

@mostbit
Copy link

mostbit commented Oct 29, 2014

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...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants