\visual studio 2008\projects\prog8\code_2.cpp(71) : warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data
\visual studio 2008\projects\prog8\code_2.cpp(81) : error C2666: 'pow' : 6 overloads have similar conversions
c:\program files\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
c:\program files\microsoft visual studio 9.0\vc\include\math.h(573): or 'long double pow(long double,long double)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(525): or 'float pow(float,float)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(489): or 'double pow(double,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(123): or 'double pow(double,double)'
1> while trying to match the argument list '(float, double)'
1>Build log was saved at "file://c:\Users\Aman\Documents\Visual Studio 2008\Projects\Prog8\Debug\BuildLog.htm"
1>Prog8 - 1 error(s), 1 warning(s)
It shouldn't have even compiled. Do you have a C++ book, or are you just trying to make things up and seeing what works? Basically, that line of code doesn't make any sense,
It's very simple:
Code:
#include <cmath>
#include <iostream>
int main()
{
float Volume = 45.0F;
float Value = pow(Volume, float(1.0/3.0));
std::cout << Value;
}
If you're using float, then the pow() function requires two float arguments. If you're using double, then the pow() function requires two double arguments (or a double and an int as the power).
Note that I stated 1.0/3.0 and not 1/3. Do you know the difference? It is very important to this entire discussion.
Bookmarks