|
-
Oct 10th, 2002, 07:13 PM
#1
Thread Starter
New Member
Why won't this code compile??
Every time I attempt to compile this code, I'm receiving a number of errors. Any ideas as to what the problem(s) might be?
Thanks.
public class MyMath
{
public static double exp(double x)
{
double dbloldGuess;
double dblnewGuess = 1 + x;
double dblcounter = 1;
do
{
dblcounter++;
dbloldGuess = dblnewGuess;
dblnewGuess = dbloldGuess + ((x ** dblcounter) / counter);
}
while (Math.abs((newGuess - oldGuess) / newGuess) > 1e-15);
return x;
}
}
-
Oct 10th, 2002, 07:37 PM
#2
Ya ya Baby!!!Me is Back
-
Oct 13th, 2002, 11:51 AM
#3
just look at the variable names. You often forget the dbl prefix.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 14th, 2002, 01:09 PM
#4
New Member
Yup CornedBee is correct you forgot the
dbl infront of several variable names:
counter, newGuess, Oldguess
and on the line
((x ** dblcounter) / counter);
get rid of one of those *
-
Oct 16th, 2002, 07:34 PM
#5
Addicted Member
if you are trying to multiply here:
((x ** dblcounter) / counter);
you only should have 1 *.
Also, avoid putting 'dbl' in front of all double variables because, as you can see, you are confusing yourself. If you need to remember what type of variable 'counter' is then keep it to one letter ( d for double, i for int, b for boolean, and so on... )
To protect time is to protect everything...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|