From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: Random Numbers? Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: <0104ms87u2hnotrl96vre4g12upkdmnrbu@4ax.com> References: X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 26 X-Trace: /K+neRiBhC4u9Nyxt9e+UnxXhwVldOEzXXxXupEpJ1GhdNsd+MbyqBsG4DJriMiy39huLJ8sK2mv!Hkda1zw7LgproxV5BMazd+5iZSk8YCLtL9cxLXi/8SCv+7qzs9YvHcZ0avMW/PgfMCtShS06RNR6!NR8i X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Tue, 04 Jul 2000 15:23:07 GMT Distribution: world Date: Tue, 04 Jul 2000 15:23:08 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Tue, 4 Jul 2000 15:22:58 +0200, "Geek86" wrote: >Which way is the best to make limited random numbers(t.ex. a random number >between 1 and 100) in C using DJGPP and Allegro? Once you've seeded the PRNG, try this: /* for random numbers 5 to 15, range = 11 and min = 5 */ int rand_range(int min, int range) { return rand() * (long long)range / (RAND_MAX + (long long)1) + min; } This gives you decent results (good enough for a game) if the range isn't really big. Search the archives at www.delorie.com for a better answer. -- Damian Yerrick "I refuse to listen to those who refuse to listen to reason." See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html This is McAfee VirusScan. Add these two lines to your signature to prevent the spread of signature viruses. http://www.mcafee.com/