There are two (like the same) algorithms with this common block:
double U_i = 1043.928480752930; double Am0 = 0; double Am1 = 0; double per_koef_usilen=48.4; qDebug()<< "Тут расчет"; Option 1:
double Y = pow((double)10.0,(double)(per_koef_usilen/20.0)); qDebug("%.14f",Y); Am0 = (double)(U_i/Y); qDebug("%.14f",Am0); Am1 = U_i/pow(10.0,(per_koef_usilen/20.0)); qDebug("%.14f",Am1); I get the result Am0 = 3.96890538899297 Am1 = 3.96890538899297
There are two of them (Am0, Am1) to check Y.
But for some reason, if you use the Y array, the result is different:
Option 2:
int K; double *Am0 = 0; if(Am0) delete []Am0; Am0 = new double[obm->stor->K]; memset(Am0, 0, obm->stor->K*sizeof(double)); Am0[k] = obm->stor->U_i[k]/pow(10.0,(obm->stor->per_koef_usilen/20.0)); qDebug("%.14f",Am0[k]); Result: Am0[1] = 3.96537540362345 . The problem is that the divergence is already on the third decimal place , if at least on the fifth , it would be normal, but it looks like a completely different number.
My goal is to understand why Am0 and Am0 are not equal to Am0[1] and why using the same variables (the only difference is that Am0 is an array) I got a different result.
double *Am0; if(Am0) delete []Am0;double *Am0; if(Am0) delete []Am0;- this is a scary ub. Collect the minimum, compiled example and then it will be possible to discuss. - KoVadimobm->stor->per_koef_usilenandobm->stor->U_i[k]before the calculations and make sure that there are the same numbers as when calculatingAm0and Am1 - avp