how long is double

From: f (ffunus_at_yahoo.com)
Date: 01/04/04

  • Next message: Derek Baker: "Re: [OT] ACCU website"
    Date: 3 Jan 2004 21:26:11 -0500
    
    

    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.

    In debug version, the print out is:
    -12.25938471938358500000 = -11.43596388399630500000,
    -0.07591666113607631300, -0.74750417425120252000,

    In the release version, the print out is:
    -12.25938471938358300000 = -11.43596388399630500000,
    -0.07591666113607631300, -0.74750417425120252000,

    The above sum = a + b + c is just a part of my computation. I found
    that my whole computation crushed in the debug version because some
    number became zero and another number divide this number. But this did
    not happened in the release version.

    Why?

    Thanks,

    ff

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


  • Next message: Derek Baker: "Re: [OT] ACCU website"

    Relevant Pages

    • Re: how long is double
      ... > I found that the debug version and release version of the same code ... Your code yields undefined behavior, because sum, a, b and c have never ...
      (comp.lang.cpp)
    • 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)
    • Re: Problem only in release version!
      ... not executed in Release mode (I believe, but I also thought Debug ... initialized variables to zero, ... The Release version will not initialize anything 'naturally' ... >>the contents of the memory addresses they happen to get assigned to). ...
      (microsoft.public.dotnet.languages.vc)
    • Re: Problem only in release version!
      ... The debug version doesn't initialize anything to zero that isn't ... the debug heap manager sets memory to certain non-zero values ...
      (microsoft.public.dotnet.languages.vc)