pitermarx / ncalc-edge Goto Github PK
View Code? Open in Web Editor NEWA clone of NCalc. Latest source. Published to Nuget.org. version 1.4.3
Home Page: http://ncalc.codeplex.com/
License: MIT License
A clone of NCalc. Latest source. Published to Nuget.org. version 1.4.3
Home Page: http://ncalc.codeplex.com/
License: MIT License
I'm trying to ignore/replace empty string but not all the empty string throw exception
Example:
new Expression("20+''").Evaluate() it will threw an exception
new Expression("0.5=''").Evaluate() it will threw an exception
'new Expression("20+''").Evaluate()' threw an exception of type 'System.FormatException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233033
HelpLink: null
InnerException: null
Message: "Input string was not in a correct format."
Source: "mscorlib"
StackTrace: " at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)\r\n at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)\r\n at NCalc.Numbers.ConvertIfString(Object s)\r\n at NCalc.Numbers.Add(Object a, Object b)\r\n at NCalc.Domain.EvaluationVisitor.Visit(BinaryExpression expression)\r\n at NCalc.Domain.BinaryExpression.Accept(LogicalExpressionVisitor visitor)\r\n at NCalc.Expression.Evaluate()"
TargetSite: {Void StringToNumber(System.String, System.Globalization.NumberStyles, NumberBuffer ByRef, System.Globalization.NumberFormatInfo, Boolean)}
new Expression("0.5=''").Evaluate()' threw an exception of type 'System.FormatException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233033
HelpLink: null
InnerException: null
Message: "Input string was not in a correct format."
Source: "mscorlib"
StackTrace: " at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)\r\n at System.String.System.IConvertible.ToDouble(IFormatProvider provider)\r\n at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)\r\n at System.Convert.ChangeType(Object value, Type conversionType)\r\n at NCalc.Domain.EvaluationVisitor.CompareUsingMostPreciseType(Object a, Object b)\r\n at NCalc.Domain.EvaluationVisitor.Visit(BinaryExpression expression)\r\n at NCalc.Domain.BinaryExpression.Accept(LogicalExpressionVisitor visitor)\r\n at NCalc.Expression.Evaluate()"
TargetSite: {Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo)}
I would like to make some changes to EvaluationVisitor and add ^ sysmbol for power function rather than pow. Currently the method is overridable but when we use the ExpressionEvaluator in the Expression class we can not inject any other class as it is hard coded there.
I did some changes in the pull request #25 to achieve the same. Can you merge these changes to master and provide the new release for the same.
New to NCalc, testing basic functionalities but when I've tried this expression
"10 / 0"
surprisingly the result evaluated to "8"...
Did I miss something?
I'll do a PR for this but I wanted to run it by you first. (i.e. make sure it's convenient and you're already tooled to run NUnit tests, such as with R#)
I don't get religious about test frameworks, but NUnit's TestCase attribute would be extremely handy to have for some of my recent tests and others. MSTest doesn't have an equivalent. Would you be ok with that switch? This one wouldn't touch the actual library code, obviously.
Hi, just downloaded the latest Visual Studio with support for migrating .net projects from using packages.config to the new Package Reference style.
Getting a Compatibility issue with NCal-Edge of:
"The assembly 'lib\lib\NCalc.dll' will be ignored when the package is installed after migration."
And the same goes for the Antlr depdency Nuget it installs.
Firstly is this an issue? And secondly is it possible for this issue to be resolved in a new version of NCalc-Edge?
More about Package Reference migration process here: https://docs.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference#how-to-roll-back-to-packagesconfig
Thanks,
James
Line 1 in 6b2e52a
Not sure if it should go here or in ncalc2, but my issue is when you do something like 2.000002 - 2.000001
you get 9.99999999695689E-07
when you should probably get something clean like 1E-06
My current fix is to surround the basic calculations in Number.cs with
private static object RoundDouble(object value)
{
if (value is double)
return Math.Round((double)value, 15);
else
return value;
}
Maybe there is a better solution, but this does prevent the problem. Let me know if you're interested and I'll submit a pull request with tests.
The wiki (operators page) mentions "Power" as a possible operator or operator type. The standard notation for power as far as I understand it elsewhere would be '^'. However '^' is used as the operator for bitwise or. After mentioning that power is possible, there is nothing further as to what the actual operator is.
I know there is Power (x, y) in the functions.
It is just that I am fairly confident that my users are going to expect to type (x^2) to square a number and I have check that the evaluator does in fact do a bit wise or of 2 against x.
Thanks for any enlightenment.
Hi.
I'm evaluating ncalc for a project where I could express values using simple formulas in an Excel-like way.
I'm using parameters to store intermediate variables. I can then reuse them in other expressions correctly.
The problem is when I try to catch circular reference problem : this must be trapped because the formula fields will be free text from the user.
NCalc.Expression exp = new NCalc.Expression("RefCroise1");
exp.Parameters["RefCroise1"] = new NCalc.Expression("RefCroise2 * 5");
exp.Parameters["RefCroise2"] = new NCalc.Expression("RefCroise1 * 12");
object result = exp.Evaluate(); // Causes stack overflow
It should have the same behaviour as another error : generate an Exception / populate the Error property.
What do you think ?
Thanks.
Regards,
mosseb.
You have two different versions here in GitHub. What is difference between NCalc-Edge and NCalc2?
https://github.com/pitermarx/NCalc2
Thanks
add docs for EvaluationOptions
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.