Closed Bykiev closed 2 months ago
It will work if you are evaluating C# math expression as a string:
Console.WriteLine("double.MaxValue + 2e+300".Evaluate(new DotNetStandartMathContext()));
If you want the evaluator understands "Invinity" string as a PositiveInfinity you can specify context:
var context = new MathContext();
context.BindVariable(double.PositiveInfinity, "Infinity");
string expr = (double.MaxValue + 2e+300).ToString(CultureInfo.InvariantCulture);
Console.WriteLine(expr.Evaluate(context));
Describe the bug
Error of evaluating the expression. 'Infinity' is not recognizable. Invalid token at position 0
To Reproduce
Steps to reproduce the issue:
string expr = (double.MaxValue + 2e+300).ToString(CultureInfo.InvariantCulture); Console.WriteLine(expr.Evaluate(CultureInfo.InvariantCulture));
Expected behavior
The result of expression evaluation should be
Double.PositiveInfinity
Actual Behavior
Exception is thrown
Hi! The evaluator returns double not a string, ToString() of the double type represents double.PositiveInfinity as "Infinity" or "∞" so I can add support of these notations to the DotNetStandartMathContext if you use this context the expression will evaluate "Infinity" or "∞" as double.PositiveInfinity. Do you agree to use the DotNetStandartMathContext? Without specified math context the evaluator supports only +-*/(). Also ScientificMathContext supports "∞" notation at the moment.
Describe the bug
Error of evaluating the expression. 'Infinity' is not recognizable. Invalid token at position 0
To Reproduce
Steps to reproduce the issue:
Expected behavior
The result of expression evaluation should be
Double.PositiveInfinity
Actual Behavior
Exception is thrown