Annotation of GNUtools/libg++/libio/dbz/random.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * random-number generator for testing
                      3:  */
                      4: static unsigned long next = 1;
                      5: 
                      6: /*
                      7:  - range - generate a random number within an inclusive range
                      8:  *
                      9:  * Algorithm from ANSI C standard.  Limitation:  max-min <= 32767.
                     10:  */
                     11: int
                     12: range(min, max)
                     13: int min;
                     14: int max;
                     15: {
                     16:        register int temp;
                     17: 
                     18:        next = next * 1103515245 + 12345;
                     19:        temp = (int)((next/65536)%32768);
                     20:        return(temp%(max - min + 1) + min);
                     21: }
                     22: 
                     23: /*
                     24:  - seed - seed random number generator
                     25:  */
                     26: void
                     27: seed(n)
                     28: long n;
                     29: {
                     30:        next = (unsigned long)n;
                     31: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.