C Different answers for a variable when running 'Debug' and 'Start without debug'
Posted
by Craz
on Stack Overflow
See other posts from Stack Overflow
or by Craz
Published on 2010-05-11T09:53:00Z
Indexed on
2010/05/11
9:54 UTC
Read the original article
Hit count: 133
I keep getting this weird output from my code everytime I use the 'start without degugging' (ctrl-F5) as opposed to normal 'debug' (F5).
When I try to find the following value of norm_differnece in debug (pressing F5) mode, it gives me the correct answer for norm_difference
normdifference = 1.000000
but in 'start without debugging' (pressing ctrl-f5) the wrong output
normdifference = 1456816083547664100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
The following is a segment of code which is gives the output Note: X[] = is a array of stored DOUBLE values
for(i=0;i<n;i++){
sum_difference += (pow((X[i*n]-X[i]),2));
}
norm_difference = sqrt(norm_difference);
for(i=0;i<n;i++){
sum_norm_1 += pow(X[i],2);
}
norm_1 = sqrt(norm_1);
//Take square root of the sum of squares for the row
printf("normdifference = %f \n norm_1 = %f \n",norm_difference,norm_1);
© Stack Overflow or respective owner