1
Vote

Expression incorrectly evaluated for NaN operands

description

For the statements below:
            string expression = "a > 0 && b < 10";
            Expression e2 = new Expression(expression);
            e2.Parameters["a"] = 10;
            e2.Parameters["b"] = double.NaN;
            Console.WriteLine(e2.Evaluate());
the result is "True". However, 10 > 0 && double.NaN < 10 should evaluate to false.

If one swaps the values for a and b, the e2's evaluation is correct, i.e. e2 evaluates to False.

comments