thumpkidd9
Programmer
I am trying to do some simple division and I am having a problem with floats. I'm not sure where the problem is but I think in here.
All I want to do is check
but what comes out in the print statement is
lot[1] = 0.000: NaN
lot[2] = 0.000: NaN
lot[3] = 0.000: NaN
lot[4] = 0.000: NaN
all of A4[] is = NaN for some reason. "num_blk" and "tries" are both floats themselves, also initialized to 0.0. Any ideas?
Code:
float A4[maxArray] = {0.0, 0.0, 0.0, 0.0, 0.0};
float lot[maxArray]= {0.0, 0.0, 0.0, 0.0, 0.0};
A4[1] = (num_blk1/tries1);
A4[2] = (num_blk2/tries2);
A4[3] = (num_blk3/tries3);
A4[4] = (num_blk4/tries4);
for(a=1;a<5;a++){
printf("lot[%d] = %.3f: %.3f\n",a,lot[a],A4[a]);
}// for
All I want to do is check
Code:
if(lot[4]==lot[a]) var=a;
but what comes out in the print statement is
lot[1] = 0.000: NaN
lot[2] = 0.000: NaN
lot[3] = 0.000: NaN
lot[4] = 0.000: NaN
all of A4[] is = NaN for some reason. "num_blk" and "tries" are both floats themselves, also initialized to 0.0. Any ideas?