Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Debug vs. Release

Status
Not open for further replies.

Jon4747

Programmer
Aug 22, 2001
234
CA
Hi,
I have created an ocx component in C++ that calculates upto 10,000 pairs of xy coordinates that get plotted in a VB GUI front end. When I run the app. using the Debug version ocx. everything is great.But using the Release version I get slightly different values e.g.

3.96588 Debug
3.96602 Release

This might not seem like much, but apply the Chaos Theory over 10,000 pairs and I get a mess. What causes this variance in value between Debug/Release and what can I do rectify it.

TIA

Jon
 
It could be a bug in the Visual Studio, a VERRRY ugly bug indeed.

I looked in msdn (offline), try to search
"INFO: Visual Studio 97 Service Pack 2 Readme".

They admit that there are some FP errors there, including FP operations inconsistency, maybe you'll find there what you are looking for.

My guess is that you should use one of their service packs; as far as I know, SP3 was released for MSVS6
HtH
[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Hi Nosferatu,

Thank-you for the response, I'm currently using sp5 on both Vb and VC++.I read the articles that MS. published about FP problems that sp3 was to fix and tried changing the release settings with regards to global optimizations but still have the same problem.

When I try a simple program like this:

#include<iostream.h>
#include<iomanip.h>

void main()
{
double Di = 0.0;
double aa = 0.0;

cout<<setiosflags(ios::fixed);
cout<<setprecision(18);
cout<<Di<<endl;
aa = 0.00006;
Di = 123.123456789;
cout<<Di<<endl;
Di = Di + aa; // Di += aa makes no difference
cout<<Di<<endl;
}
The output is this
0.000000000000000
123.123456789000000
123.123516789000010

The second to last digit is where my problem starts

Jon


 
The example that you have put up here, is not an issue between debug and release versions, but is infact the very nature of Floating Point numbers.

Even though you have set precision to 18, this is only the output precision. The number being stored is just an approximation of the number you have, and in that regard the addition is of two approximate numbers. Hence the result will only be approximate, and I would say that being accurate to 17 signifant figures, is a pretty good approximation.
 
Hi apkohn,

Maybe the second example is not a Debug/Release issue but the the first one certainly is. I just ran the executable again and these are the results after only four pairs (x values).
Debug 15.7574184458542
Release 15.7546337877014

As you can see they start to vary at the third decimal place,by the time I get to the 100th pair the results are miles apart and at the 10,000th pair... well as I said,its a real mess.

Jon
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top