berthelot samuel wrote:
Hi,
I'm trying to do this :
double term2 = 0.0;
term2 = pow (0.1, 2.0);
the only thing I get in term2 is 1. it should be 0.01. Why is that ? I
don't get it... pow() is supposed to work with double and to return
double...
A hint for the future: When an inexplicable problem has
baffled you, you are perhaps the least-qualified person to
decide which parts of your code are relevant to the problem
and which are not involved. Take your current difficulty,
for example: I can think of two different possible causes,
yet you have prevented me from seeing enough of your code
to determine which is the actual problem. There is nothing
at all wrong with the two lines you have shown, hence they
are not the cause of the problem. The problem arises from
the pieces you have not shown, so I can only guess what it
might be.
"Doctor, I am in pain."
"Where does it hurt?"
"Not in my left knee."
Next time, please post the *smallest* *complete* program
that demonstrates your difficulty.
Likely cause #1: You forgot to #include <math.h>, which
declares the pow() function and thus makes it known to the
compiler.
Likely cause #2: `term2' is calculated correctly, but
there is something wrong with the way you display the value.
Perhaps you wrote `printf("%d\n", term2)', using "%d" when
you should have used something like "%g" or "%f".
--
Er*********@sun.com