🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #7252

Re: rand() within a range.

#7252
From: Aaron Friesen
Date: Wed, 05 Dec 1990 23:50
13 lines
806 bytes
sheoak.bcae.oz (David Thiele) /  4:20 pm  Dec  3, 1990 /
> Is there a way to generate random numbers within a certain range in 
> Lattice C??. Ive done it with the following code but it's not very
> elegant (or fast!),

[ Code Deleted... ]

Simply taking

	rand() % range

or something similar should give you what you want.  This will be fast and
about as "random" as the code you are currently using.
Technical Details
Message-ID: <1230001@hpfcbig.SDE.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!hplabs!hpfcso!hpfcbig!aaronf
References: <666@sheoak.bcae.oz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!hplabs!hpfcso!hpfcbig!aaronf
From: aaronf@hpfcbig.SDE.HP.COM (Aaron Friesen)
Newsgroups: comp.sys.amiga.tech
Subject: Re: rand() within a range.
Message-ID: <1230001@hpfcbig.SDE.HP.COM>
Date: 5 Dec 90 23:50:49 GMT
References: <666@sheoak.bcae.oz>
Organization: HP SESD, Fort Collins, CO
Lines: 13