cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/02/13:30:38

From: cpw10 AT columbia DOT edu (Chester Wong)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: random numbers error in DJGPP
Date: Sun, 02 Feb 1997 17:13:39 GMT
Organization: Columbia University
Lines: 25
Message-ID: <32f4ca80.4194982@news.cc.columbia.edu>
References: <32F44A89 DOT 3142 AT ix DOT netcom DOT com>
NNTP-Posting-Host: dialup-21-8.cc.columbia.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

If you only call it once without setting the seed, the rand function
returns 0 on the first call.  However, if you call it in a loop, say 10
times, you will see the value change.  Since the rand function is
deterministic, the same values will always appear.  Other than that, I see
no reason why you should always get 0 or 1.

Chester

On Sun, 02 Feb 1997 00:04:25 -0800, Terence Ramos <de-bug AT ix DOT netcom DOT com>
wrote:

>Hello...
>
>I have been having trouble to get DJGPP to give me random numbers.  I am
>using the function rand()... this is how my source looks like
>
>number = rand() % 100 + 1;
>
>that should give me a random number from 1 to 100 right?  well i keep on
>getting the same number which is 1.  So i took out the + 1 part and now
>i only get 0.  whats wrong here?  Any help would be appreciated...
>
>[Terence Ramos       ]
>[de-bug AT ix DOT netcom DOT com]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019