For this code
#include <math.h>
int main()
{
float x = 1.5f;
float y = 0.0f;
y = pow(x, 6) * 235809835.41 - pow(x, 5) * 2110439254.2 + pow(x, 4) *7869448124.8 - pow(x, 3) * 15648965509 + pow(x, 2) * 17503313074 - (x)* 10440563329 + 2594694745;
y = pow(x, 6) * 235809835.41 - pow(x, 5) * 2110439254.2 + pow(x, 4) *7869448124.8 - pow(x, 3) * 15648965509 + pow(x, 2) * 17503313074 - (x)* 10440563329 + 2594694745;
return 0;
}
I get the following error log -
maincpp.cpp(6) : warning C4244 : '=' : conversion from 'double' to 'float', possible loss of data
maincpp.cpp(6) : error C2146 : syntax error : missing ';' before identifier ''
maincpp.cpp(6) : error C2065 : '' : undeclared identifier
Line 6 does not compile. The most surprising thing is that line 7 compiles, even if it is identical to line 6. So, if I comment out line 6 and save line 7, the program will successfully compile.
I am on Windows 8 64 bit and this program was written in Visual Studio 2013 as a Win 32 console application.
In production code, I would stop all float literals with f. But in any case, I do not expect a compiler error without it.
The equation was generated in Excel.
source
share