This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] PATCH -- Fix for PR 15619

On Sun, May 30, 2004 at 11:52:51AM +0100, Paul Brook wrote:
> > See attached.
> > fortran.diff is applied to gcc/fortran.
> > random.c.diff is applied to random.c
> I tweaked the int->float conversion routines, and applied as follows.
> Paul

Thanks!  But, your tweaking has broken the REAL(8) version.

      kiss = (((GFC_UINTEGER_8)kiss_random_kernel ()) << 32)
	     + kiss_random_kernel ();
      *x = (GFC_REAL_8)kiss / (GFC_REAL_8)(~(GFC_UINTEGER_8) 0);
  while (*x != 0);

*x has a 1 in 2**123 chance to equal 0.  Looks like an infinite
loop to me.

I also do not like your change to the REAL(8) version because
the the following program no longer produces the same sequence
of numbers in the first 7 (or 8) digits for REAL(4) and REAL(8).
This means a person doing Monte Carlo cannot switch precision
and generate compatible sequences.

program s

   integer i
   real(4) x4(10)
   real(8) x8(10)

   call random_seed
   call random_number(x4)

   call random_seed
   call random_number(x8)

   do i = 1, 10
      print '(I2,2X,E15.6,E22.15)', i, x4(i), x8(i)
   end do

end program s

kargl[206] gfc -o uu uu.f90
kargl[207] ./uu
 1     0.126499E+00 0.126499085373039E+00
 2     0.651118E+00 0.827013909818962E-01
 3     0.827013E-01 0.330153673957584E+00
 4     0.600953E+00 0.401973397956495E+00
 5     0.330153E+00 0.248005078713098E+00
 6     0.302073E+00 0.972308359552425E+00
 7     0.401973E+00 0.576130797541992E-01
 8     0.851402E-01 0.116375109993003E+00
 9     0.248005E+00 0.102418855622136E+00
10     0.314663E+00 0.432082466613380E+00


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]