Re: how long is double

From: Thomas Mang (a9804814_at_unet.univie.ac.at)
Date: 01/04/04


Date: 4 Jan 2004 06:25:34 -0500


f schrieb:

> I have this
>
> double sum, a, b, c;
> sum = a + b + c;
> printf("%.20f = %.20f, %.20f, %.20f", sum, a, b, c);
>
> I found that the debug version and release version of the same code
> give me different result. I am using VC++ 6.0.

Your code yields undefined behavior, because sum, a, b and c have never
been initialized before using them for computations / printing.
So the outcome of the program is undefined, thus anything might happen -
and different outcome between debug and release version is just one
possibility.

regards,

Thomas

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated. First time posters: Do this! ]



Relevant Pages

  • Re: how long is double
    ... > double sum, a, b, c; ... You used a, b, and c without initializing them. ... > I found that the debug version and release version of the same code ... Your massive crossposting is very bad usenet manners. ...
    (comp.lang.cpp)
  • Re: how long is double
    ... > double sum, a, b, c; ... > I found that the debug version and release version of the same code ... Apparently the discrepancy is between -12.25938471938358500000 ... intermediate register, and in debug mode ...
    (comp.lang.cpp)
  • how long is double
    ... double sum, a, b, c; ... I found that the debug version and release version of the same code ... number became zero and another number divide this number. ...
    (comp.lang.cpp)
  • Re: Baffling problem with links
    ... and you want to sum this specified row from JAN to NOV (if this is the ... "Stephen POWELL" schrieb im ... >> "Frank Kabel" wrote: ... >>> to SUM ...
    (microsoft.public.excel.worksheet.functions)
  • Re: How to deploy Window service project?
    ... "Cylix" schrieb: ... I test and debug the project in my computer by just rebuild the file, ...
    (microsoft.public.dotnet.languages.vb)