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
11
votes
4 answers

Get the parameters in an expression using NCalc

I have an expression which I want to parse to get a list of all used parameters. For example: "X + 5 / (Y - 1)" should give me the following result: X, Y I already use NCalc in my project; so is it possible to use NCalc to get the parameters…
Preli
  • 2,953
  • 10
  • 37
  • 50
7
votes
5 answers

NCalc: Are there alternatives?

Does anyone know of a more up-to-date expression evaluator than NCalc? The last release was in 2011 and a (very) quick Google search returned pretty much nothing from what I could see.
Skulmuk
  • 587
  • 4
  • 8
  • 19
6
votes
2 answers

NCalc specify type

We have a generic calculation routine using Ncalc to evaluate a string. However we are running across a problem when the values in a multiplication are small enough that Ncalc sees them as int however the result is too big for an int. Example: …
user2380829
  • 63
  • 1
  • 5
4
votes
4 answers

NCalc date operations

I am using NCalc in a project. Is there a way to do date operations like #16/02/2013# - #15/02/2013# = 1 I can't seem to be able to produce a result. Expression.Evaluate(); Results is null for the above expression. I can compare two dates, but is…
Daniel
  • 1,391
  • 2
  • 19
  • 40
3
votes
1 answer

Stop nCalc from using ToUInt16()?

I am trying to use nCalc in my application but am running into issues with it wanting to convert to UInt16 for whatever reason and causing an error. string evalstring = "-.503937 ^ 2"; Expression e = new Expression(evalstring); this.Value =…
Wobbles
  • 3,033
  • 1
  • 25
  • 51
2
votes
1 answer

NCalc Evaluate() gives wrong answer

I have a problem with NCalc: I'm trying to implement a way to add an expression to my program by writing it in a textbox and then have the program to use it to sum/multiply variables. Here is an example: Expression expr = new…
Alewoor
  • 23
  • 2
2
votes
1 answer

in NCalc why does 'if (12 > 8)' resolve to false?

Brand New to NCalc. I have a formula to be evaluated and Im getting some unexpected (to me) results. The @T_No_Starters parameter used = 12. If the formula is if (@T_No_Starters >= 8 ,'T','F') Result FALSE If the formula is if (@T_No_Starters >=…
user1500403
  • 551
  • 8
  • 32
2
votes
1 answer

NCalc creating custom functions in vb.net

What is the equivalent code for creating a custom function in vb2010 instead of c#? Expression e = new Expression("SecretOperation(3, 6)"); e.EvaluateFunction += delegate(string name, FunctionArgs args) { if (name ==…
2
votes
1 answer

How to add a new function to Ncalc

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…
eddy
  • 4,373
  • 16
  • 60
  • 94
1
vote
1 answer

How to use ncalc in a wp7 app?

i am new to wp7 programming and c# and i want to use a mathematical parser for my app. I found ncalc that everyone says it works great for windows phone, but i don't know how to use it inside my app.I have downloaded the binaries and i added them in…
Josh
  • 53
  • 1
  • 7
1
vote
1 answer

Mathematical expression evaluator which incorporates units of measure

Similar to this question but different. Lots of good answers there, but none do Units of Measure. How about a .NET compatible (even through COM, if necessary) mathematical expression evaluator which incorporates units of measure? I've tried NCalc…
1
vote
1 answer

Calculating a String in C#

I want to calculate a string in C# using either NCalc or DynamicExpresso library, the problem is, when the calculation gets complex and the numbers are big, it returns the wrong result. For example the code below returns -808182895 when it should…
joseph
  • 37
  • 7
1
vote
1 answer

How to make NCalc to compute using decimal type instead of double?

I'm currently making a calculator using windows form and I'm using the string data type to store the math expression entered by the user. Except, when wanting to convert it to a data type which can give me the result I need to use an evaluator so I…
KarimCool
  • 21
  • 3
1
vote
0 answers

How do I stop NCalc from writing to the console?

I'm using NCalc to do mathematical evaluations in a Console application. It keeps spewing tons of information to the console (Specifically when the Evaluate() function is executed). I was unable to find documentation to stop this. For…
adinas
  • 4,150
  • 3
  • 37
  • 47
1
vote
2 answers

how to handle null in IF expression of NCALC

I have a complex NCALC if expression which goes something like this: if ( {0} == null || {1} == 0 ,{2} * ({3} * {4} + {5}), ({2} * ({3} * {4} + {5}))/{1}) This gives me some unexpected error such as below: missing ')' at '==' at line 1:6 missing…
1
2 3 4