Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odd Compiler Error in C++ (VC compiler)

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.

like image 833
The Vivandiere Avatar asked Mar 19 '23 02:03

The Vivandiere


1 Answers

Looks like you have a stray right-to-left mark in Line 6 before the semicolon:

... 2594694745<U+200F>; 
like image 184
mandaleeka Avatar answered Mar 31 '23 23:03

mandaleeka