Re: random() function produces wrong range

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org, pgsql-general(at)postgreSQL(dot)org
Subject: Re: random() function produces wrong range
Date: 2000-08-01 20:20:44
Message-ID: Pine.BSF.4.10.10008011248400.25036-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


On Tue, 1 Aug 2000, Tom Lane wrote:

> Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> > Actually, on my machines, both man pages for rand() and random() say
> > they return values between 0 and RAND_MAX (whether that's true or not
> > is another matter). In my case RAND_MAX==INT_MAX so the change wouldn't
> > be a problem, but it might be problematic on some of the 64 bit machines.
>
> Oh, that's interesting. What platform do you use? If RAND_MAX applies
> to random() on some machines that'd probably explain why the code is
> written like it is. But on my box (HPUX) the rand() function is old
> and crufty and considerably different from random().

That's from a pair of linux boxes, although checking on a FreeBSD box a
friend has, his boxes man pages show the range as explicitly 0 to 2^31-1
as your box does.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Smith 2000-08-01 20:40:33 Re: [HACKERS] Re: random() function produces wrong range
Previous Message Felipe Alvarez Harnecker 2000-08-01 19:09:19 SQL guru needed

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 2000-08-01 20:27:57 Re: Anyone care about type "filename" ?
Previous Message Tom Lane 2000-08-01 19:49:16 Re: pg_dump & ownership (again)