From: ptc AT sdiv DOT cray DOT com (Paul Cheng) Date: Wed, 2 Nov 1994 10:42:17 -0600 To: turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp Subject: Re:Is it random number sequence? Cc: djgpp AT sun DOT soe DOT clarkson DOT edu References: <00986D2B DOT 0E0EEC20 DOT 13893 AT ludens DOT elte DOT hu> <9411020317 DOT AA26989 AT shako DOT sk DOT tsukuba DOT ac DOT jp> On November 2, you (Stephen Turnbull) wrote: > > printf(" %d", (rand()>>16)&3); > I don't think it is a good idea to play with bits in the returned number at all. If you want a 3 bits random number, you should do this: printf(" %d", (int)( 8 * (double) rand() / RAND_MAX)); The numbers you get depend on how good the random number generator is. RAND_MAX is 65536 in djgpp and 32767 in my sun work station. Hope this helps. Paul Cheng.