From: William Heymann Newsgroups: comp.os.msdos.djgpp Subject: Help! Random is not working right Date: Mon, 07 Apr 1997 23:05:54 -0400 Organization: University of Colorado at Boulder Lines: 20 Message-ID: <3349B612.68C@ucsu.Colorado.edu> Reply-To: heymann AT ucsu DOT Colorado DOT edu NNTP-Posting-Host: tele-anx0138.colorado.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I am having a major problem with my program. The random fuction does not seem to be working right. random() & 9 only returns 0, 1, 8, and 9. I put the funcition in a loop and that is the only numbers it ever returns. I then changed the 9 to a 5 and then I got 0,1,4, and 5. I need to get all the intergers within that range not just the four extremes. Can anybody explain why this is happening. I am using c++ and here is a sample code statement that illustrates my point. #include #include #include #include int n; for(n=0; n < 10; n++) cout << (random() & 9); Thank you for your time.