array, I/O file and standard deviation (c++)
<pre><code>    double s_deviation(double data[],int cnt, double mean)
   {
      int i;
      double sum= 0;
      double sdeviation;
      double x;

    //x = mean(billy,a_size);

      for(i=0; i&lt;cnt; i++)
      {    
         sum += ((data[i]) - (mean));
      } 

        sdeviation = sqrt(sum/((double)cnt));

      return sdeviation;
   }
</code></pre>

<p>When I cout the result from this function, it gave me NaN.
I tested the value of (mean) and data[i] using
return data[i] and return mean
they are valid. </p>

<p>when i replaced mean with an actual number, the operation returned a finite number.
but with mean as a variable, it produced NaH.
I can't see anything wrong with my code at the moment.</p>

<p>Again, I am sure mean, data are getting the right number based on those tests.</p>

<p>Thank you</p>
