home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / gnu / gcc / bug / 3109 < prev    next >
Encoding:
Text File  |  1993-01-05  |  1.1 KB  |  40 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!hertz.njit.edu!dic5340
  3. From: dic5340@hertz.njit.edu (David Charlap)
  4. Subject: Bug in gcc's rand() function.
  5. Message-ID: <1993Jan4.210729.28287@njitgw.njit.edu>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: New Jersey Institute of Technology, Newark, N.J.
  8. Distribution: gnu
  9. Date: Mon, 4 Jan 1993 21:07:29 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 27
  12.  
  13. When the stdlib.h rand() function is called, the sequence is
  14. repeatable, mod 8.
  15.  
  16. For example, the following code:
  17.  
  18.     #include <stdio.h>
  19.     #include <stdlib.h>
  20.  
  21.     main() {
  22.       int x;
  23.  
  24.       for (x=0; x<100; x++)
  25.         printf ("%d   ", rand() % 8);
  26.     }
  27.  
  28. always produces the following repeating sequence:
  29.  
  30.     6   7   4   5   2   3   0   1
  31.  
  32. I have tested it on the OS/2 2.0 port of gcc and the Dec-Ultrix
  33. version, and I get the same result in both cases.
  34. -- 
  35.   |)  David Charlap          | .signature confiscated by FBI due to
  36.  /|_  dic5340@hertz.njit.edu | an ongoing investigation into the
  37. ((|,)                        | source of these .signature virusses
  38.  ~|~
  39.  
  40.