make certain, that -log() doesn't overflow and assign a suitable maximum number instead.

This commit is contained in:
Axel Kohlmeyer 2016-09-15 14:55:32 -04:00
parent 2fb666dc69
commit 400ef87c05
1 changed files with 6 additions and 1 deletions

View File

@ -49,7 +49,12 @@ double FixTempCSVR::gamdev(const int ia)
x=1.0;
for (j=1; j<=ia; j++)
x *= random->uniform();
x = -log(x);
// make certain, that -log() doesn't overflow.
if (x < 2.2250759805e-308)
x = 708.4;
else
x = -log(x);
} else {
restart:
do {