Re: win32 random number generator

Tom Lane <[email protected]> Mon, 22 Aug 2005 17:32:39 -0400
Newsgroups gmane.comp.db.postgresql.devel.win32
Message-ID <[email protected]>
"Merlin Moncure" <[email protected]> writes:
> Looks like this in lrand48(void):
> //return ((long) _rand48_seed[2] << 15) + ((long) _rand48_seed[1] > 1);

> is supposed to be this:
> return (long)((unsigned long) _rand48_seed[2] << 15) + ((unsigned long)
> _rand48_seed[1] >> 1);

Hmm, _rand48_seed is unsigned short, so casting to either long or
unsigned long should zero-extend, and then it doesn't matter whether
the shifts think it's signed or not.  In short, that shouldn't change
the behavior unless your compiler is broken.

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org