pow() doesnt return a double?
Code:
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double result, x = 3.0, y = 2.0;
result = pow(x, y);
cout << result << endl;
system("PAUSE");
return 0;
}
The above gives me a result of 9 instead of 9.0
as the book here says.
Same thing w/ abs() or fabs() or floor() etc. The arguments are doubles but the value returned are integers.
I did something wrong or do I need to use the "cout.setf....cout.precision" thingy, but this book doesnt say anything abt it.
Thanx.
Re: pow() doesnt return a double?
Quote:
Originally posted by FloatingPoint
The above gives me a result of 9 instead of 9.0
as the book here says.
the computer will truncate any extra zeroes... set precision to 1 if you want them to show up... it truncates them at a sig digit because you don't want 9.00000000000000 to show up...
Re: Re: pow() doesnt return a double?
Quote:
Originally posted by major_small
the computer will truncate any extra zeroes... set precision to 1 if you want them to show up... it truncates them at a sig digit because you don't want 9.00000000000000 to show up...
Yea, I guess so.
Thanx again.