Visual Studio and .NET Framework Home
In VS2005 C++, Zero reported as negative zero for double type
as By Design
8/9/2007 2:52:15 PM
User(s) can reproduce this bug
In VS2005 C++, if double type zero times negative one, the result will become negative zero. But in VS2003, the result is expected as zero. And then if integer type zero times negative one, the result will become zero which we expected.
Visual Studio 2005 (All Products and Editions) Service Pack 1
Windows XP Professional
Operating System Language
Steps to Reproduce
Here is the code snippet to reproduce issue:
double dZero = 0.0;
int nZero = 0;
int nNegativeOne = -1;
double dResult = dZero * nNegativeOne;
int nResult = nZero * nNegativeOne;
CString strText, strText2;
strText will be -0.00 and strText2 will be 0
strText will be 0.00 and strText2 will be 0.
Note: 0.00 should not have sign.
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 8/15/2007 at 10:44 AM
Actually, the correct result is -0.0 and VS 2005 gets is right. VS 2003 had a bug. For integer types there is no -0.
You should consult the floating-point documentation on special values: -0.0, Inf, NaN.
VC++ Libraries Dev Lead
on 8/9/2007 at 7:46 PM
Thanks for your feedback. We have reproduced this bug on WinXP SP2 and OrcasBeta2VSTS, and we are sending this bug to the appropriate group within the Visual Studio Product Team for triage and resolution. Thank you, Visual Studio Product Team.
on 8/9/2007 at 7:34 PM
Thank you for your feedback. We are currently investigating. If this issue is urgent, please call support directly (see http://support.microsoft.com). Thank you, Visual Studio Product Team.
to post a workaround.
Please enter a workaround.
© 2013 Microsoft