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
0
votes
3 answers

NCalc precision problems

I got some rounding problems with NCalc. My problem is quite simple. just add 0.5 and 0.5555. expected result is 1.0555. This i need to round to 3 fractions. 1.056 float and double should not cause me any precision problems at a 5 digit number.…
Evelie
  • 2,919
  • 2
  • 14
  • 21
0
votes
0 answers

Static parameters don't get applied

I recently tried nCalc for parsing formula from strings. But when I tried static parameters I always ended with null as a result. Here is the example I tried: Expression e = new Expression("[bProd] + [bUp]"); e.Parameters["bProd"] =…
JJR
  • 773
  • 2
  • 13
  • 32
0
votes
1 answer

NCalc expression evaluation error for custom function

I have an expression which has all calls to all custom functions. IIF(FVAL(DES_CODE)=1039 OR FVAL(DES_CODE)=1040 OR FVAL(DES_CODE)=1034,0,TBLEVA(PTAX, FVAL(HOPO_GRS))) When trying to evaluate this expression the NCalc engine is producing an error.…
Soham Dasgupta
  • 5,061
  • 24
  • 79
  • 125
0
votes
2 answers

Calculating String Values

I am making a program in C# that takes an equation from the user input and evaluates it. At the moment I have a way of it calculating the user input and also taking values from stored variables such as x. The equation the will enter will be…
Colm Clarke
  • 480
  • 1
  • 7
  • 23
0
votes
2 answers

ncalc thousands comma formatted fails to evaluate?

I am currently using ncalc library to do several evaluation and get the result out of it. Right now I have found a problem where if I have a price in the format "1,234.01" it will fail to evaluate my expression. The current workaround I've used was…
Guapo
  • 3,446
  • 9
  • 36
  • 63
0
votes
2 answers

Overriding "if" statement in NCalc

I am struggling to understand the NCalc and I have few questions. 1) If I have an expression like "if(CLOSE<2.3,ROC(OPEN),HIGH)" and ROC is a custom function. Does the result of "ROC(OPEN)" is available when the condition "CLOSE<2.3" is being…
balan
  • 179
  • 1
  • 5
  • 11
0
votes
1 answer

Mathematical Expression using NCalc

I am trying understand the expression library NCalc. http://ncalc.codeplex.com If I have a script as below, SET A = CLOSE - OPEN; SET B = A>0.5 AND CLOSE > HIGH If(HIGH > 5, ROC(CLOSE), B) CLOSE is a List of double, OPEN is a List of…
balan
  • 179
  • 1
  • 5
  • 11
-1
votes
3 answers

Evaluating an arbitrary string expression in c#

I have a method that needs to return true or false based upon a string expression that is passed in to it. The string expression could look like: ("ASDF"=="A" || "BED"!="BED") && (5>=2) or any valid C# expression that evaluates to a Boolean result.…
Greg W
  • 89
  • 1
  • 7
-1
votes
1 answer

Using NCalc in Visual Studio 2010 - VB.Net

As the title states, I need to use NCalc in Visual Studio 2010. I am writing a program that will calculate a multi-step math problem in VB, but I'm not quite sure how I'd use NCalc. The user inputs a math problem into a text box, then clicks a…
Kuuchuu
  • 326
  • 1
  • 4
  • 13
-2
votes
2 answers

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

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#…
pitermarx
  • 908
  • 1
  • 9
  • 22
-2
votes
1 answer

How to install NCalc in Visual Basic .NET project?

I'm making a programme which has to evaluate function expressions like f(x) = x^2+6x-9, using Visual Basic (.NET). I suppose the only way I can do this is by using NCalc, so I downloaded it and I can see that it is installed under 'Project > Manage…
Tim65
  • 1
  • 6
-8
votes
2 answers

Since when does 3 / 5 = 0?

So I've got a nice convoluted piece of C# code that deals with substitution into mathematical equations. It's working almost perfectly. However, when given the equation (x - y + 1) / z and values x=2 y=0 z=5, it fails miserably and inexplicably. The…
ArtOfCode
  • 5,702
  • 5
  • 37
  • 56
1 2 3
4