Giter VIP home page Giter VIP logo

ncalc-edge's People

Contributors

gitter-badger avatar pitermarx avatar spudstuff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ncalc-edge's Issues

Input string was not in a correct format.

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)}

Need extensibility for the Evaluation Visitor

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.

Division by 0?

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?

Switch to NUnit?

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.

Support for Package Reference style of using NuGet Package

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

Rounding last digit of calculations

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.

Power operator?

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.

Circular reference cause stack overflow

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.