November 2nd, 2007

Much ado about nothing part 94

C++ in Visual Studio 2005...

float f=0.0f;
f*=-1000.0f;
CString s;
s.Format(L"%f",f);
AfxMessageBox(s);

-0.000000

This has changed since C++ in Visual Studio 2003.

I am more than prepared to believe that this is correct by the laws of God, man, the ANSI C++ committee, the IEEE etc. but I suspect many people will be surprised to see them, particularly as negative zeros are fragile beasts and adding positive zero to them will turn them into positive zero.

EDITED... Although I am surprised at the floating point behaviour, I should clarify that it is the formatting that has changed, the -0.00s were lurking there quietly before.