For this code,
#include <math.h>
int main()
{
float x = 1.5f;
float y = 0.0f;
/*line6*/ 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; // error
/*line7*/ 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 fails to compile. What I find most astonishing is that line 7 compiles even though it is identical to line 6. So, if I comment out line 6 and retain line 7, then the program compiles successfully.
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 terminate all float literals with f. But in any case, I don't expect a compiler error without it.
The equation was generated in Excel.
Looks like you have a stray right-to-left mark in Line 6 before the semicolon:
... 2594694745<U+200F>;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With