Questions tagged [ncalc]

NCalc is a mathematical expressions evaluator in .NET.

NCalc is a mathematical expressions evaluator in .NET. NCalc can parse any expression and evaluate the result, including static or dynamic parameters and custom functions.

NCalc project page: https://github.com/ncalc/ncalc.

57 questions
1
vote
1 answer

How do I find the length of a number using NCalc built- in functions?

I am using NCalc in my project to evaluate expressions. The framework includes a set of already implemented functions which can be found here. I am interested in calculating the length of a number or a string. Can I achieve that using just the…
ArsenalRocks
  • 339
  • 1
  • 4
  • 12
1
vote
2 answers

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

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…
1
vote
2 answers

Convert NCalc expression to string

I'm have to calculate string input using NCalc, but I would like to save it (result) as a string. How do I do that? Expression expressionEv = new Expression(expressionProccessed); string value = expressionEv.Evaluate (); Following code returns…
107MP
  • 171
  • 1
  • 9
1
vote
1 answer

nCalc sum all given arguments

I am working on one project that will utilize nCalc to work with some calculation. These calculation will also contain some function.g.: sum(), avg() etc. Very much like Excel function: sum() will summarize all of the numbers that are provided in…
marpik
  • 56
  • 7
1
vote
1 answer

NCalc mathematical expression in C# -

I'm using NCalc to create Mathematical expression in C#: Expression e = new Expression("2 + 3 * 5"); Debug.Assert(17 == e.Evaluate()); But second line gives me an error - "Operator == cannot be applied to operands of type int and…
user2262230
  • 199
  • 1
  • 3
  • 17
1
vote
1 answer

NCalc evaluation error no viable alternative at input ','

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…
Soham Dasgupta
  • 5,061
  • 24
  • 79
  • 125
0
votes
0 answers

How to extract function from mathematical expression

I have a string which is entered by users which can have custom defined functions. We are using Ncalc to do the evaluations using "EvaluateFunction" event. I would like to know if there is a way to get the functions user has entered. example string…
mmek123
  • 13
  • 5
0
votes
1 answer

Find Parameters in NCalc Expression

In principle my question is answered here, but in my case the variables are not simply X or Y, but pretty complex. My expression looks like "plc3.gs_Data[1].tag1 + plc3.gs_Data[1].tag2" and I would like to get a List {"plc3.gs_Data[1].tag1",…
Batox
  • 574
  • 1
  • 4
  • 16
0
votes
1 answer

NCalc expression validation

How can I validate NCalc expression? I want to use NCalc for evaluating if/else/endif condition in my simple custom language for defining sequence of steps. Main program will provide some parameters for conditions. Sequences are defined by user, so…
Marian
  • 1
  • 1
0
votes
0 answers

Ncalc, set parameters

i recently approached to NCalc library to execute some expressions retrieved from a db. So, i created a method that process expression's formula and after, bind the values for the parameters. At a first look, i believed that when i build an…
0
votes
1 answer

VB co-ordinate calculation with NCalc

I need this to loop from -n to n but this only produces one co-ordinate so far. Does anyone know any easy quick fixes so I can have values from -n to n (step 1) subbed into the y equation id input? I'm also not sure if I'm using the expression…
0
votes
0 answers

Mysql service not getting started on start up on some pc with windows 10

I am facing issue on both windows 10 pro and windows 10 home single language version. First of all the mysql service is not being started automatically and moreover I am forced to restart/recycle application pool for my ncalc.dll to work properly to…
Rohit G
  • 1
  • 1
0
votes
1 answer

Simplifying and evaluating mathematical strings

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…
ryan
  • 23
  • 4
0
votes
1 answer

NCALC : Array compare

I'm trying to compare a array of elements to one value, is there any way to do that using ncalc? Example: new Expression(ruleExpression.Replace(" [1,2,3] > 1 and 2 < 3 and 2 == 2").Evaluate(); The result that I want is FALSE to ([1,2,3] > 1 ),…
0
votes
1 answer

Mathematical expression in string: Alternatives to NCalc

I need to read from file mathematical expression and evaluate it's value. Example expression formats are as follow: "5" - constant "3.1415 * 0.25" - constant expressions "{0} - 50" - expressions with value placeholders (String.Format())…
Nethanek
  • 23
  • 6