From: Tobias Schlüter Date: Sun, 13 Jun 2004 17:48:23 +0000 (+0200) Subject: random.c (random_r4): Burn a random number. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9d409075cb2e052ce66b91bdc791b8c6cf37dcbb;p=gcc.git random.c (random_r4): Burn a random number. 2004-06-13 Steven G. Kargl * random.c (random_r4): Burn a random number. (random_r8): fix infinite loop. From-SVN: r83062 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index d665c973e04..1d4b42365cc 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,4 +1,9 @@ -2004-6-12 Bud Davis +2004-06-13 Steven G. Kargl + + * random.c (random_r4): Burn a random number. + (random_r8): fix infinite loop. + +2004-06-12 Bud Davis Steve Kargl PR gfortran/15292 diff --git a/libgfortran/intrinsics/random.c b/libgfortran/intrinsics/random.c index bfda3437f91..73a6cede0f0 100644 --- a/libgfortran/intrinsics/random.c +++ b/libgfortran/intrinsics/random.c @@ -462,6 +462,9 @@ prefix(random_r4) (GFC_REAL_4 *x) { kiss = kiss_random_kernel (); *x = (GFC_REAL_4)kiss / (GFC_REAL_4)(~(GFC_UINTEGER_4) 0); + /* Burn a random number, so the REAL*4 and REAL*8 functions + produce similar sequences of random numbers. */ + kiss = kiss_random_kernel (); } while (*x == 1.0); @@ -482,7 +485,7 @@ prefix(random_r8) (GFC_REAL_8 *x) + kiss_random_kernel (); *x = (GFC_REAL_8)kiss / (GFC_REAL_8)(~(GFC_UINTEGER_8) 0); } - while (*x != 0); + while (*x == 0); }