Path: chuka.playstation.co.uk!news From: Javier Ventoso Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Randomizer problem Date: Fri, 11 Jun 1999 15:05:10 +0200 Organization: PlayStation Net Yaroze (SCEE) Lines: 30 Message-ID: <37610986.1D795D07@mundivia.es> References: <7jqv39$qtv7@chuka.playstation.co.uk> NNTP-Posting-Host: info19555204183.mundivia.es Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5 [en] (Win98; I) X-Accept-Language: en Tones wrote: > Hi, > > Probably not the correct newsgroup to go through, but as it seems to be one > of the most frequented, so I figured I'd post here. > > Basically, I am having problems with the rand() function in C. Numerous > manuals state that this routine returns a value between 0 and RAND_MAX. Not > a problem in itself, but how do I set RAND_MAX ? > > For example, I would like to obtain a totally random value between 0-320. > However, to do this I need to set the maximum value I would like. From my > understanding of other languages, normally a rand fuction returns a value > like 0.78283929 - which you would multipy by your maximum number to obtain a > value between that range. How on earth do you do it in C ? > > Any help greatly appreciated, > > Cheers! > > Tones 8) Have you tried this ? rand()%320 ( return 0-319 )