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.
@SimpleFunction
public double MethodName (double a)
return
I want the method to return the square root of a.
@SimpleFunction(description = "")
public Object SquareRoot(int number) {
return Math.sqrt(number);
}
1 Like
@Faraz_Firoz
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";
}else{
//it is 0
return "Zero";
}
}
5 Likes
system
Closed
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.