From 9d409075cb2e052ce66b91bdc791b8c6cf37dcbb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Schl=C3=BCter?= Date: Sun, 13 Jun 2004 19:48:23 +0200 Subject: [PATCH] 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 --- libgfortran/ChangeLog | 7 ++++++- libgfortran/intrinsics/random.c | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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); } -- 2.30.2