-
Notifications
You must be signed in to change notification settings - Fork 97
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
OptionForceIntegerNumbersEvaluationsAsDoubleByDefault
leads to not recognising three parameter version of Math.Round
#112
Comments
Yes of course as in C# You can't put a So for your case there are 5 solutions to manage it.
Round(1,0,MidpointRounding.AwayFromZero)
Math.Round(1,(int)0,MidpointRounding.AwayFromZero)
evaluator.PreEvaluateFunction+= PreEvaluateFunction;
private void PreEvaluateFunction(object sender, FunctionEvaluationEventArg e)
{
if(e.Name.Equals("Round") && e.This is ClassOrEnumType classOrTypeName && classOrTypeName.Type == typeof(Math))
// use e.EvaluateArgs() that you can cast and use how you want.
// and return the result in e.Value
}
evaluator.EvaluateParameterCast += EvaluateParameterCast;
Math.Round(1d,0,MidpointRounding.AwayFromZero) |
Thanks, it works well with: evaluator.EvaluateParameterCast += Evaluator_EvaluateParameterCast;
[...]
private static void Evaluator_EvaluateParameterCast(object? sender, ParameterCastEvaluationEventArg e)
{
if (e.MethodInfo.DeclaringType == typeof(Math) && e.MethodInfo.Name == "Round" && e.ParameterType == typeof(int) && e.OriginalArg is double original)
{
e.Argument = (int) original;
}
} |
The code
gives the error
instead of the expected result "1".
This came about in 1.4.31.0 and worked in 1.4.30.0 (but 1.4.31.0 is a good fix for #110, so thanks for that!)
The text was updated successfully, but these errors were encountered: