This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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] Implement irand(), rand(), and srand() for G77 compatibility


On Sun, May 30, 2004 at 03:39:59PM -0700, Steve Kargl wrote:
> On Sun, May 30, 2004 at 11:10:20PM +0100, Paul Brook wrote:
> > > GFC_REAL_4 prefix(rand) (GFC_INTEGER_4 *i)
> > > {
> > >   return (GFC_REAL_4) (prefix(irand)(i) - 1) / (GFC_REAL_4)(GFC_RAND_M1);
> > > }
> > 
> > This returns values in the range [0,1]
> > We really need a reliable routine to convert from integer to real.
> 
> Actually, I think its worst than that.
> 
>    rand_seed = GFC_RAND_A * rand_seed % GFC_RAND_M;
> 
> If GFC_RAND_A * rand_seed = GFC_RAND_M, then rand_seed becomes
> 0, which is really bad.  We need

I should think a little more before I embarass myself
on a public mailing list.

-- 
Steve


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