Date: Wed, 7 Dec 94 00:17:15 -0500 From: dj AT stealth DOT ctron DOT com (DJ Delorie) To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: better rand() This source demonstrates a better rand() function, which is similar in algorithm to the one I'm using in V2. Let me know if anyone finds any non-randomness in this one. Note: this test shows how non-random V1's rand() is, if you just comment out the rand() here and use the system one. Enjoy! DJ --------------- #include int rand() { static unsigned long long next=0; next = next * 1103515245L + 12345; next = (next<<15) ^ (next >> 27); return next; } main() { int mx, my, w; GrSetMode(GR_biggest_graphics); mx = GrSizeX(); my = GrSizeY(); w = GrWhite(); while (!kbhit()) GrPlot(rand()%mx, rand()%my, w); getkey(); GrSetMode(GR_default_text); return 0; }