diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index d665c973e0476ca205eea082d326265e2b26530e..1d4b42365cc98d01f0108069822178eb0c88447a 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,4 +1,9 @@ -2004-6-12 Bud Davis <bdavis9659@comcast.net> +2004-06-13 Steven G. Kargl <kargls@comcast.net> + + * random.c (random_r4): Burn a random number. + (random_r8): fix infinite loop. + +2004-06-12 Bud Davis <bdavis9659@comcast.net> Steve Kargl <sgk@troutmask.apl.washington.edu> PR gfortran/15292 diff --git a/libgfortran/intrinsics/random.c b/libgfortran/intrinsics/random.c index bfda3437f91de2046cf96e1a6bc01d9de969212d..73a6cede0f0cd550545a7ae83d4b38decb1a2f59 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); }