Tom Lane <tgl(at)sss(dot)phg(dot)pa(dot)us> writes:
> Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu> writes:
> > The Linux man pages indicate that the behavior and underlying
> > implementation of random() and rand() are the same (so I just picked
> > one).
> Ah, well, there's your problem. Whoever did this part of the library
> on Linux took shortcuts. On older-line systems, rand() is a
> considerably older and crummier generator than random(). It would
> definitely not be a wise decision to use rand() instead.
> I believe using random() is the right thing. The portability bug here
> is the assumption that RAND_MAX applies to random() (or is even defined;
> none of the man pages I've looked at so far mention it). But all the
> machines say that the output of random() is 31 bits, so INT_MAX should
On an i386 machine, certainly; but not on an Alpha or a Sparc.
Probably safer to use (2**31)-1, which is what my (NetBSD) man page
FWIW, I believe random(3) running on NetBSD/alpha, for example, will
return a 31-bit result.
System Administrator, RightNow Technologies
"Is this going to be a stand-up programming session, sir, or another bug hunt?"
In response to
pgsql-hackers by date
|Next:||From: Tom Lane||Date: 2000-08-03 19:57:47|
|Subject: Re: Toasting more system-table columns |
|Previous:||From: Mike Mascari||Date: 2000-08-03 19:36:50|
|Subject: Re: comparing rows|
pgsql-general by date
|Next:||From: BJB||Date: 2000-08-03 21:53:54|
|Subject: Database security via a special ODBC connection possible?|
|Previous:||From: Federico Sevilla III||Date: 2000-08-03 18:10:42|
|Subject: PHP and PostgreSQL (was: Unions in views)|