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

evaluate dynamically created formula on large (in memory) flat table

I am currently using this code: using System; using NCalc; namespace SandboxConsoleApp { class Program { static void Main(string[] args) { double[,] data = new double[100, 10]; Random random = new…
cs0815
  • 16,751
  • 45
  • 136
  • 299
0
votes
1 answer

NCalc missing EOF

i was trying to evaluate expression using NCalc, Expression ex = new Expression("3[X] + 4[Y]"); ex.Parameters["X"] = 10; ex.Parameters["Y"] = 20; I have been getting this error: missing EOF at '[x]' at line 1:1 Not sure why I have getting this…
user
  • 91
  • 2
  • 12
0
votes
1 answer

NCalc expression.evaluate output different from when I compute the expression manually

Here is my code: Dim ex As String = "(((105 * 4000) * 0.20) - ((0 + 10000) * (105 * 4000)) / ((105 * 4000) + Round((52 * 18192.31),0))) / 24" Dim x As New Expression(ex) Dim result As Decimal = x.Evaluate Console.WriteLine(result.ToString("N")) it…
napster
  • 13
  • 5
0
votes
1 answer

NCalc allows me to use { } [ ] in a math operation?

So, I want to give the answer of { [ 4+(3+2)]} I already have this in a String, but when i tried to use DataTable, it give me error.. Or another way to calculate it with the { } [ ] Thanks
albita
  • 29
  • 7
0
votes
1 answer

Ncalc formula evaluates to unexpected result

I have a formula to be evaluated "6*6*6*6*6*6*5*6*6*6*5*6*5" Ncalc returns = -1031662592 when the answer should be (I expect to be) = 7558272000 the code is fairly straight forward Function StraightEval(Formula As String) Try Dim X As…
user1500403
  • 551
  • 8
  • 32
0
votes
1 answer

Ncalc how to evaluate multi-value string parameters

I am using Ncalc to evaluate the presence of some string values if (@Xval = 'Z','T','F') this works well when @xval is inputted as a parameter as a single value(@Xval = 'Z'). That will return a true evaluation. I am now looking to evaluate the same…
user1500403
  • 551
  • 8
  • 32
0
votes
1 answer

NCalc evaluation is wrong?

I am trying to evaluate the following expression: 7088.800/(((((((24.65995+24.43061+24.54517+24.65192)/4)-32.0)*5/9)+273.15)/288.15)^.5) If you are asking yourself why I didn't use Sqrt() instead of ^0.5 it's because I'm doing some things with the…
Matthew Goulart
  • 2,873
  • 4
  • 28
  • 63
0
votes
1 answer

How do I use Ncalc.Expression to solve for y?

I want to input this string: "pow(y,2) = 4 - pow(x,2)" (in other words, y^2=4-x^2) and make "x" = 1, then have it evaluate and give me the value of y. How do I do this?
0
votes
1 answer

Ncalc divide decimal by decimal

Is there a way to divide a decimal by another decimal in Ncalc? When I try Expression exp = new Expression("119 / 1.19"); try { MessageBox.Show(exp.Evaluate().ToString()); } catch (Exception ex) { …
ComanderKai77
  • 460
  • 6
  • 14
0
votes
0 answers

c# ncalc - line 1:1 missing EOF at 'x'

Im playing around with a genetic algorithm for solving eqvations. So I've found this lib called NCAL which seems to be a nice way to go. So I've tried to generate som random strings that will become NCALC Expressions like this: private…
Jedi Schmedi
  • 746
  • 10
  • 36
0
votes
1 answer

NCalc custom function referencing a Guid

I'm trying to use NCalc to parse some formula from JSON files. However sometimes I'm needing to reference another object via GUID and get that objects formula: public class FooObject { NCalc.Expression expression; double Value; public void…
se5a
  • 97
  • 10
0
votes
2 answers

NCalc Expression.Evaluate() gives wrong output

We have code like ncalcFormula = "[OD1000]=[OD1100]+[OD1200]+[OD1350]+[OD1450]" var expression = new Expression(ncalcFormula); foreach (FormulaParameter fp in parsedParameters) { expression.Parameters[fp.QuestionKey] = fp.Value; } …
Girish Chaudhari
  • 1,607
  • 5
  • 16
  • 24
0
votes
1 answer

Can NCalc be configured to evaluate a bool to 0 or 1?

I just got caught by surprise because management thinks it's a good idea to use Boolean expressions in calculations such as x = (y < 4) * 1 + (z < 8) * 4 ... I use NCalc for formula evaluation, unfortunately NCalc complains because I'm trying to…
Thorsten Westheider
  • 10,572
  • 14
  • 55
  • 97
0
votes
0 answers

NCalc using symbols in custom function name

Let's say that in my expression input I like to make functions stand out with a special prefix like $: var expr = "Your name is $proper([firstName]) $upper([lastName])"; where I would write custom functions for $proper and $upper. However, I get…
drzaus
  • 24,171
  • 16
  • 142
  • 201
0
votes
1 answer

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

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…
Liron Harel
  • 10,819
  • 26
  • 118
  • 217