Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqrt math function is not working #81

Open
ramakrishnareddy2108 opened this issue Sep 24, 2020 · 5 comments
Open

sqrt math function is not working #81

ramakrishnareddy2108 opened this issue Sep 24, 2020 · 5 comments

Comments

@ramakrishnareddy2108
Copy link

getting 'FunctionCallElement: Could find not function 'sqrt(Int32)'' error while using sqrt math operator

@hunkydoryrepair
Copy link
Contributor

sqrt takes a double as an argument, but it should convert for you.
I created a test and it passes without issue, so provide code/expression if this is still an issue:


            ExpressionContext context = new ExpressionContext();
            context.Imports.AddType(typeof(Math));
            IDynamicExpression e1 = context.CompileDynamic("sqrt(16)");

            Assert.AreEqual(4.0, e1.Evaluate());

@da-sann
Copy link

da-sann commented Feb 22, 2022

Following code will return Flee.PublicTypes.ExpressionCompileException: 'FunctionCallElement: Could find not function 'sqrt(Decimal)''

        ExpressionContext context = new ExpressionContext();
        context.Imports.AddType(typeof(Math));
        context.Variables["a"] = Convert.ToDecimal(199);
        IDynamicExpression eDynamic = context.CompileDynamic("sqrt(a) + pi");
        var result = eDynamic.Evaluate();

@shawndewet
Copy link

Odd, it passes on my system.

@harrymattison
Copy link

I also get this exception when calling context.CompileGeneric<double>("sqrt(9.9)")
{"FunctionCallElement: Could find not function 'sqrt(Double)'"}
Image

@harrymattison
Copy link

update - it works if you add
context.Imports.AddType(typeof(Math));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants