-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Labels
Description
In C#
the call
var x = (int) 3.6;
produces x = 3
.
The same call in ExpressionEvaluator produces x = 4
instead.
This is due to the usage of
...
return Convert.ChangeType(value, conversionType);
in line 4150, which for the given example resolves to Convert.ChangeType(3.6, typeof(int))
which indeed resolves to 4.
I understand if this is a design decision, but it might be a source of issues. We use ExpressionEvaluator to simulate C#
code, which means for us, it is non-expected behavior.
For our intents and purposes it would be great to have an option to turn integer casting from round
to truncate
e.g. with
evaluator.OptionTruncateOnIntegerCast = true;
This would preserve current behavior but enable a more correct simulation of C#
behavior.