Skip to content

OptionForceIntegerNumbersEvaluationsAsDoubleByDefault leads to exception when dividing  #110

@midgleyc

Description

@midgleyc

The code

var evaluator = new ExpressionEvaluator()
{
    OptionForceIntegerNumbersEvaluationsAsDoubleByDefault = true 
};

string expression = "3/Math.Round(Avg(1,2),MidpointRounding.AwayFromZero)";

Console.WriteLine(expression);
Console.WriteLine(evaluator.Evaluate(expression));

gives the error

Unhandled exception. Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Operator '/' cannot be applied to operands of type 'double' and 'decimal'

It worked in 1.4.20 and first stopped working in 1.4.21. Math.Round is picking the decimal overload when I'd expect it to pick the double overload. It works without OptionForceIntegerNumbersEvaluationsAsDoubleByDefault.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions