In the snippet below I put a breakpoint at the first line. The local variables generated at start follow. Note that iGenerationMax is huge even though it is set to 99. I need help figuring out why it changed. Any help proffered will be much appreciated. :)

======== snippet=====================

int iGenerationMax = 99;

double fProbability = 0.500;

while (!Found && (i < iGenerationMax)){

double t = i;

// if (k <= n && k > 0)

{ cur = PosteriorDensity(t, mu, k, n);

CumProb = CumProb + (prev + cur) / 2.0; }

if ((CumProb > fProbability) && !Found)

{ if (abs(PrevCumProb - fProbability) < abs(CumProb - fProbability)) {

iGeneration = i - 1;}

else {

iGeneration = i;

Found = true; } }

prev = cur;

PrevCumProb = CumProb;

Found = true;

i = i + 1; }

return iGeneration; }

=======Local Variables=============

Variable | Value |
---|---|

prev | 0 |

cur | 0 |

CumProb | 0 |

PrevCumProb | 0 |

Found | false |

i | 1 |

iGeneration | 1305670058 |

iGenerationMax | 1071124578 |

fProbability | 0 |

If the break point was set @ " int iGenerationMax = 99; "

I assume the function stack(& all other locals) are not yet initialized & are bound to have Garbage Values in them.You should check thier values after assignment.