Hi Jon,

in the code below ( from FGJSBBase.h ), there is a potential divide by
zero error reported by the compiler :


  static double GaussianRandomNumber(void)
  {
    static double V1, V2, S;
    static int phase = 0;
    double X;

    V1 = V2 = S = X = 0.0;

    if (phase == 0) {
      do {
        double U1 = (double)rand() / RAND_MAX;
        double U2 = (double)rand() / RAND_MAX;

        V1 = 2 * U1 - 1;
        V2 = 2 * U2 - 1;
        S = V1 * V1 + V2 * V2;
      } while(S >= 1 || S == 0);

      X = V1 * sqrt(-2 * log(S) / S);
    } else
      X = V2 * sqrt(-2 * log(S) / S);   <<====  S == 0.0

    phase = 1 - phase;

    return X;
  }

Regards,
-Fred

-- 
Frédéric Bouvier
http://my.fotolia.com/frfoto/   Photo gallery
http://fgsd.sourceforge.net/    FlightGear Scenery Designer


------------------------------------------------------------------------------
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to