I have written some code which is not behaving as expected.
double y,ymag,yval;
y=2.0/(double) fftpoints;
ymag=0.0;
for(x=0; x <= fftpoints; x++){ //mag=sqrt(Real^2+Imag^2)*(2/fftpoints)
yval= sqrtdp(powdp(fftbuf[x*2],2)+powdp(fftbuf[x*2+1],2))*y;
bin[x]=yval;
if (yval > ymag){
ymag=yval;}
}
This routine is calculating magnitudes as the post processing for my FFT and trying to extract the bin with the largest magnitude. The bold statement is not processing as I would expect. When emulating, I see that the yval variable contains the proper 64bit word (number), but after the assignment to ymag, ymag only has the lower word, and the upper word is all 0s. Is this not the proper method to do this type of double to double assignment? Is there an alternate method or trick to making this work?