dadhi/FastExpressionCompiler

Wrong output when comparing NaN value

hyh opened this issue · 2 comments

hyh commented

GreaterThanOrEqual/LessThanOrEqual generates wrong result when parameter is NaN.

        var p1 = Expression.Parameter(typeof(double));
        var e1 = Expression.GreaterThanOrEqual(p1, Expression.Constant(0.0));
        var e2 = Expression.Lambda<Func<double, bool>>(e1, p1);
        var cmp1 = e2.Compile();
        var cmp2 = e2.CompileFast();
        Console.WriteLine("{0} {1} {2}", double.NaN >= 0.0, cmp1(double.NaN), cmp2(double.NaN));

resulting:

False False True

Did not see the NaN is coming :)
Thanks, will check.

On it.