matheval / expression-evaluator-c-sharp

Matheval is a mathematical expressions evaluator library written in C#. Allows to evaluate mathematical, boolean, string and datetime expressions
https://matheval.org/
MIT License
107 stars 29 forks source link

Set the Culture for expression evaluation #3

Open butulia opened 1 year ago

butulia commented 1 year ago

Hi @matheval

First of all thank you very much for your work, I am very satisfied with the library. Very good work.

Evaluating formulas with numeric literals can give errors depending on the thread's CurrentCulture. It would be very helpful if, when instantiating an Expression, you could indicate the culture you want to work with, for example, through a chained method, just like you have SetScale().

Proposal example: new Expression("18293.3402*403.282").SetCulture(CultureInfo.InvariantCulture).Eval<decimal>();

Thank you very much in advance, regards

matheval commented 1 year ago

@butulia Thank for your feedback. I promised another guy that I would fix #2 issue by this year July but I haven't done yet. I will try to combine #2 and #3(your issue) on this year and release new nuget version.

matheval commented 1 year ago

Thank you very much. New version of Nuget will be upload soon