zzzprojects / Eval-Expression.NET

C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
https://eval-expression.net/
Other
449 stars 86 forks source link

Wrong calculations with Carets as Exponent #159

Open benjaminrupp opened 2 months ago

benjaminrupp commented 2 months ago

Hi,

I have a problem with carets is an expression. I am using the flag UseCaretForExponent = true.

10^3 = 1000 like expected but 0.466*10^3 is not 466 like expected but 101.1946.

This is quite an issue for us, because this is not expected.

Thanks

Benjamin

JonathanMagnan commented 2 months ago

Hello @benjaminrupp ,

Thank you for reporting. I can confirm that we have this issue.

The 0.466*10^^3 will work correctly (2 caret), but indeed, using it with only 1 caret leads to this issue.

We will look at it.

Best Regards,

Jon

JonathanMagnan commented 2 months ago

Hello @benjaminrupp ,

Just to let you know that a fix has been merged and will be available on July 23

Best Regards,

Jon

benjaminrupp commented 2 months ago

Thanks. This is great

JonathanMagnan commented 2 months ago

Hello @benjaminrupp ,

The v6.1.8 has been released.

Let us know if everything is working as expected.

For your information, in C# Eval Expression, we use a right-associativity in case of multiple caret such as a^b^c. You can see a good comparison of which language use this one or the expected result here: https://codeplea.com/exponentiation-associativity-options

Best Regards,

Jon