Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 3740 | Replies: 6
![]() |
•
•
Join Date: Jun 2005
Posts: 14
Reputation:
Rep Power: 4
Solved Threads: 0
Hi,
Has anyone had the following problem?
When I run the following code (just using Notepad and my DOS prompt):
public class MathFunctionsApp2
{
public static void main(String[] args)
{
int b = -50;
double x = 25.0;
double y = 3.0;
double z = 4.0;
System.out.println("cbrt(x) = "+ Math.cbrt(x));
System.out.println("hypot(y,z) = "+ Math.hypot(y,z));
System.out.println("log10(y) = "+ Math.log10(y));
System.out.println("signum(b) = "+ Math.signum(b));
}
}
It won't compile - it doesn't like SOME of the mathematical functions provided by the Math Class. (See error note below)
MathFunctionsApp2.java:13: cannot resolve symbol
symbol : method cbrt (double)
location: class java.lang.Math
System.out.println("cbrt(x) = "+ Math.cbrt(x));
^
MathFunctionsApp2.java:15: cannot resolve symbol
symbol : method hypot (double,double)
location: class java.lang.Math
System.out.println("hypot(y,z) = "+ Math.hypot(y,z));
^
MathFunctionsApp2.java:17: cannot resolve symbol
symbol : method log10 (double)
location: class java.lang.Math
System.out.println("log10(y) = "+ Math.log10(y));
^
MathFunctionsApp2.java:19: cannot resolve symbol
symbol : method signum (int)
location: class java.lang.Math
System.out.println("signum(b) = "+ Math.signum(b));
^
4 errors
However, it will accept some of the other Mathematical functions, such as sqrt, max, exp, etc. (I just didn't include them here - but they do work!)
Oh, and I also CAN get it to run if I just use TextPad.
Would love any advice I can get!
Thanks.
Has anyone had the following problem?
When I run the following code (just using Notepad and my DOS prompt):
public class MathFunctionsApp2
{
public static void main(String[] args)
{
int b = -50;
double x = 25.0;
double y = 3.0;
double z = 4.0;
System.out.println("cbrt(x) = "+ Math.cbrt(x));
System.out.println("hypot(y,z) = "+ Math.hypot(y,z));
System.out.println("log10(y) = "+ Math.log10(y));
System.out.println("signum(b) = "+ Math.signum(b));
}
}
It won't compile - it doesn't like SOME of the mathematical functions provided by the Math Class. (See error note below)
MathFunctionsApp2.java:13: cannot resolve symbol
symbol : method cbrt (double)
location: class java.lang.Math
System.out.println("cbrt(x) = "+ Math.cbrt(x));
^
MathFunctionsApp2.java:15: cannot resolve symbol
symbol : method hypot (double,double)
location: class java.lang.Math
System.out.println("hypot(y,z) = "+ Math.hypot(y,z));
^
MathFunctionsApp2.java:17: cannot resolve symbol
symbol : method log10 (double)
location: class java.lang.Math
System.out.println("log10(y) = "+ Math.log10(y));
^
MathFunctionsApp2.java:19: cannot resolve symbol
symbol : method signum (int)
location: class java.lang.Math
System.out.println("signum(b) = "+ Math.signum(b));
^
4 errors
However, it will accept some of the other Mathematical functions, such as sqrt, max, exp, etc. (I just didn't include them here - but they do work!)
Oh, and I also CAN get it to run if I just use TextPad.
Would love any advice I can get!
Thanks.
•
•
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation:
Rep Power: 9
Solved Threads: 18
Well, none of those are functions in the math class.
You can find a list here:
http://java.sun.com/j2se/1.4.2/docs/...lang/Math.html
I can help you with a few of those:
To get the cube root:
Math.pow(base,3);
To get log base 10 of X:
int answer = Math.log(x)/Math.log(10);
To get hypotenuse a little more work is needed:
Math.sqr((Math.pow(a,2)+Math.pow(b,2));
I think that will work, not sure.
I don't know what you want on your last thing though.
You can find a list here:
http://java.sun.com/j2se/1.4.2/docs/...lang/Math.html
I can help you with a few of those:
To get the cube root:
Math.pow(base,3);
To get log base 10 of X:
int answer = Math.log(x)/Math.log(10);
To get hypotenuse a little more work is needed:
Math.sqr((Math.pow(a,2)+Math.pow(b,2));
I think that will work, not sure.
I don't know what you want on your last thing though.
•
•
Join Date: Jun 2005
Posts: 14
Reputation:
Rep Power: 4
Solved Threads: 0
•
•
•
•
Originally Posted by server_crash
Well, none of those are functions in the math class.
You can find a list here:
http://java.sun.com/j2se/1.4.2/docs/...lang/Math.html
I can help you with a few of those:
To get the cube root:
Math.pow(base,3);
To get log base 10 of X:
int answer = Math.log(x)/Math.log(10);
To get hypotenuse a little more work is needed:
Math.sqr((Math.pow(a,2)+Math.pow(b,2));
I think that will work, not sure.
I don't know what you want on your last thing though.
Thanks for the website though - very useful!
PS The signum returns the sign of the argument. I have no idea why this is useful. Just was trying out what the book suggested...
•
•
Join Date: Jun 2005
Posts: 14
Reputation:
Rep Power: 4
Solved Threads: 0
Aha!! I figured it out!!
The math functions I was looking at are new to Java's version 1.5.0_04!!
For the very latest list:
java.sun.com/j2se/1.5.0/docs/api/java/lang/Math.html
And.... it turns out that my path was still pointing to the old version of Java (1.4 etc), NOT 1.5.0!
Hope someone can make good use of this!
The math functions I was looking at are new to Java's version 1.5.0_04!!
For the very latest list:
java.sun.com/j2se/1.5.0/docs/api/java/lang/Math.html
And.... it turns out that my path was still pointing to the old version of Java (1.4 etc), NOT 1.5.0!
Hope someone can make good use of this!
•
•
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation:
Rep Power: 9
Solved Threads: 18
I see what it is. TextPad must come with extra classes that make things easier. A lot of times you will get things like this. I know normally you'll find an easier class to help out with reading and writing data.
To get the sine of a number in the normal methods:
Math.sin(x);
You won't be able to use those methods you have unless TextPad actually came with them, or you download them. I would suggest using the normal classes though.
To get the sine of a number in the normal methods:
Math.sin(x);
You won't be able to use those methods you have unless TextPad actually came with them, or you download them. I would suggest using the normal classes though.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode