double P = 3.5/(.1 * sqrt(2.0*3.14159)) * exp(-pow(5.0,2) / (2.0*pow(.1,2))); cout << P << endl; if (P==0) cout << "P is zero!" << endl;
Is this underflowing so it is getting rounded to zero? The problem is that I am taking the log of this, so if it is zero it breaks everything because it is -inf instead of a normal double. Is there a way to prevent this?