In Maths PI = 3.14...
this is float value so you need to return it into float type like this,
@SimpleFunction(description = "")
public float Pi() {
return (float)Math.PI;
}
this is float value so you need to return it into float type like this,
@SimpleFunction(description = "")
public float Pi() {
return (float)Math.PI;
}
do you have any documentation about that?
may be but really as it said it is a "double" value
i did as
@SimpleFunction(description = "")
public double Pi() {
return (float)Math.PI;
}
thats why error mentioned -double to int
This one is not possible
correct code is
@SimpleFunction(description = "")
public double Pi() {
return (double)Math.PI;
}
First you need to learn about data types some keyword and OOPS concepts
I think @HIFI_APPS is right because I saw this code :
@SimpleFunction (description = "Calculates the area of Circle. Input should be in same unit.")
public double AreaOfCircle ( double radius )
{
return (double) (Math.PI * (radius * radius));
}
i only know three types int,string,float now double where can i learn all
yes it worked
there are many types of datatypes in java
Primitive datatypes
Boolean
char
byte
short
int
long
float
double
Non-primitive datatypes
String
objects
etc..
i remember all this in childhood except short,objects
i don't have any idea to mark solution to anyone,both helped me in this if i marked 1 other will be sad so let it be without a mark
there difference between float and double size of float is 4 byte = 32 bit and size of double is 8 byte = 64 bit.
give the mark to yourself
PI
is defined as a double in Java (ref) and you don't need to cast the return to double since everything will be promoted to double for the math operations since they involve at least one double.
please remember to follow the naming conventions
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.