Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!hpda!hpwala!hpavla!gary From: gary@hpavla.HP.COM (Gary Jackoway) Newsgroups: comp.lang.c Subject: Re: Random number generator Message-ID: <940001@hpavla.HP.COM> Date: 22 Dec 89 14:58:29 GMT References: <83943@linus.UUCP> Organization: Hewlett-Packard Avondale Division Lines: 18 > I was trying to generate a random number bewteen 0 and maxlongint (i.e. 2^32) > on my machine (80386 with Interactive). The rand() function that I have > returns a psuedo-random number between 0 and MAXINT (which in this case > is 32768). ---------- Simply put two rand's together: longrand = (unsigned long) rand() | ((unsigned long) rand() << 32); This should give you a uniform distribution. I should warn you that rand() is often NOT a good random number generator, so if the application is sensitive, be sure to run randomness tests on your long random numbers. No charge, Gary Jackoway