How do I calculate square root in an extension?

How do you calculate a square root in an extension? I want to use it to calculate other complicated stuff.

I tried, but I stuck there.

  public double MethodName (double a)

I want the method to return the square root of a.

@SimpleFunction(description = "")
public Object SquareRoot(int number) {
return Math.sqrt(number);
1 Like

This code is wrong... You are returning something in void method...
This should be something like this , which return double

public double SquareRoot(int number){
return Math.sqrt(number);

Also you might have to check if number is positive or not , As it will return NaN for negative return , to check if number is positive or not,

public String Check(int number){
if(number > 0){
return "Positive";
}else if(number < 0){
return "Negative";
//it is 0
return "Zero";

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.