L
loftusoft
While debugging the following code:
#include <iostream>
using namespace std;
int main()
{
float f = 583312.0F * 0.1F;
cout << f << endl;
return 0;
}
The value of "f" as reported by the debugger is "58331.199" instead of
"58331.2". Note that the console output will correctly display
"58331.2". However, this is not just a "debugger-display" problem, this
problem was found since the errant data is actually being output to
Matlab data files.
I've tested this sample code on VC++ 6, 2002, and 2005. Both 2002 and
2005 exhibit this problem. Version 6 at least shows the correct result
while debugging.
Can this be "fixed" with some compile/link option? (Needed most for
2002)
Is there a patch available? A reasonable work-around?
This is so surprising I must be overlooking something very basic.
Mike
#include <iostream>
using namespace std;
int main()
{
float f = 583312.0F * 0.1F;
cout << f << endl;
return 0;
}
The value of "f" as reported by the debugger is "58331.199" instead of
"58331.2". Note that the console output will correctly display
"58331.2". However, this is not just a "debugger-display" problem, this
problem was found since the errant data is actually being output to
Matlab data files.
I've tested this sample code on VC++ 6, 2002, and 2005. Both 2002 and
2005 exhibit this problem. Version 6 at least shows the correct result
while debugging.
Can this be "fixed" with some compile/link option? (Needed most for
2002)
Is there a patch available? A reasonable work-around?
This is so surprising I must be overlooking something very basic.
Mike