On Wed, 21 Nov 2001, Chris G Haravata wrote:
> anybody have a random number generator application? i've searched through > sourceforge.net and freshmeat.net and both came out nada. help will be very > much appreciated. thanks! If you are interested in writing our own random number generator, you can read Donald Knuth's classic treatise on random number generation: "The Art of Computer Programming, Vol 2: Seminumerical Algorithms". Of course, if your requirements are not so sophisticated, you can always use familiar tools: #include <stdlib.h> This defines "int rand(void)" which returns a random number between 0 and RAND_MAX (INT_MAX?). So that you do not get the same sequence of random numbers, you will want to use a random seed, "void srand(unsigned int seed)". Of course you can use "time_t time()" from <time.h> for the seed, after properly casting to unsigned int. Do it the hard way, and use Knuth's Vol 2. You will get better random numbers. PMana _ Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph To leave: send "unsubscribe" in the body to [EMAIL PROTECTED] To subscribe to the Linux Newbies' List: send "subscribe" in the body to [EMAIL PROTECTED]
