Celestial Weasel (celestialweasel) wrote,
Celestial Weasel
celestialweasel

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.
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 6 comments