ncalc

Simplifying and evaluating mathematical strings [closed]

风流意气都作罢 提交于 2020-01-06 04:46:04
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 14 days ago . What would be the simplest way to evaluate/simplify a mathematical string in VB ? For example: "k*k+(5+2*5)k+k" would simplify to "k^2+15k+k" and "5^2+3" would evaluate to 28 . To evaluate, I'm using NCalc by simply using the evaluate function, but it doesn't simplify expressions.

Operator '+' can't be applied to operands of types 'decimal' and 'double' - NCalc [closed]

不打扰是莪最后的温柔 提交于 2019-12-13 11:18:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm using NCalc to evaluate complex expressions. But I've found a major problem. A simple formula like new Expression("Abs(-1) + Cos(2)").Evaluate() throws the exception Operator '+' can't be applied to operands of types 'decimal' and 'double In C# code Math.Abs(-1) + Math.Cos(2) works, so either I'm doing

Operator '/' can't be applied to operands of types 'decimal' and 'double' - NCalc

↘锁芯ラ 提交于 2019-12-13 04:55:46
问题 I'm trying to run this formula in NCalc: "( Abs([a] - [b]) / ( ([a] + [b]) / 2.0 ) ) * 100" I get the error: Operator '/' can't be applied to operands of types 'decimal' and 'double' The [a] and [b] parameters are passed as Decimals. I tried putting 'm' on the 2 and 100 like so: "( Abs([a] - [b]) / ( ([a] + [b]) / 2m ) ) * 100m" But it throws an exception: Additional information: extraneous input 'm' expecting ')' at line 1:36 I followed this question, but it didn't help me. The same question

How to escape single quote within string variable in NCalc.Expression - Backslash didn't work

白昼怎懂夜的黑 提交于 2019-12-13 01:59:17
问题 I am using NCalc.Expression to evaluate a condition which involves comparison with string values that contain single quote within them. In NCalc, string is represented using single quote instead of double quotes. Ex: [variable1]=='Sample's Data' In order to escape the single quote, I tried appending a backlash like this - [variable1]=='Sample\'s Data' But when this is assigned to a string variable, it removes the backslash as - [variable1]=='Sample's Data' and after assigning this to the

NCalc evaluation error no viable alternative at input ','

删除回忆录丶 提交于 2019-12-11 06:19:21
问题 I'm trying to evaluate an expression using NCalc . iif(fval(hopo_pfd)="true",fval(hopa_basic)*12%,0) But this expression is producing an error no viable alternative at input ',' at line 1:46 All functions declared here are custom functions. But the event EvaluateFunction is not even raised. Please help. 回答1: I believe you have invalid syntax. The expression: fval(hopa_basic)*12% includes the modulo % operator, but you haven't provided a divisor. If you meant 12 percent , then it should be

How to add a new function to Ncalc

戏子无情 提交于 2019-12-05 04:21:21
问题 I'm using Ncalc in my new project and it already has almost everything I need . I said almost everything, because now I need to expand some functions and also add new ones such as : nth root,random, etc Do you know if anyone has already implemented those functions? Or could you give me any tips or guides to extend the function list of Ncalc??? Thanks in advance. 回答1: If I understand correctly: As much as I was using it is by creating a static function private static void

How to add a new function to Ncalc

﹥>﹥吖頭↗ 提交于 2019-12-03 21:54:54
I'm using Ncalc in my new project and it already has almost everything I need . I said almost everything, because now I need to expand some functions and also add new ones such as : nth root,random, etc Do you know if anyone has already implemented those functions? Or could you give me any tips or guides to extend the function list of Ncalc??? Thanks in advance. If I understand correctly: As much as I was using it is by creating a static function private static void NCalcExtensionFunctions(string name, FunctionArgs functionArgs) { if (name == "yourfunctionname") { var param1 = functionArgs