www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/11/10/01:47:18

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: random number generator
Organization: Pin Eight Software http://pineight.8m.com/
Message-ID: <ki5n0t4s6ldr1gftmo95i6bs5sg0c7dg20@4ax.com>
References: <GnIO5.10922$Wd3 DOT 1222073 AT typhoon DOT mn DOT mediaone DOT net>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 22
X-Trace: /KtlGUj/39YbQVHgrszKfMhTnP+Ngk7iSqfvlBc5Xy8XcbhJsFrBbvossm/avXJtNJ5ICp6TksBJ!3oyH5BOaSIT4e0cCa/Tyn0dHClt2zmMLxvC7y8kqjbwtV/PclfEed5biPrr2ua0fWYAacVFq/Vz/!l8zmaQ==
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: Fri, 10 Nov 2000 06:33:42 GMT
Distribution: world
Date: Fri, 10 Nov 2000 06:33:42 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Fri, 10 Nov 2000 01:41:58 GMT, "tritesnikov"
<tritesnikov AT hotmail DOT com> wrote:

>srand(time(0));
>a = rand() % 5;
>
>Error: implicit declaration of function 'int time(...)'

1. The dice formula is
     a = (rand() >> 4) % 6 + 1;
This drops four extremely non-random low-order bits from the returned
pseudorandom value, and then scales the rest between 1 and 6.

2. #include <time.h>

-- 
<O
( \   GNOME vs. KDE: the game!
 X    http://pineight.8m.com/nes.htm

This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses.  http://www.mcafee.com/

- Raw text -


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