From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro ex11.c Date: Mon, 9 Feb 1998 22:29:35 +0000 Organization: None Distribution: world Message-ID: References: <34DF7294 DOT 21D0 AT home DOT com> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 18 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Dan writes: >here's the question, in this small snippet of the code.. > > hotspot[c] += (random() & 7) - 3; > >what does "random() & 7" do? You can probably guess what random() does (see "info libc al random" for details). The "& 7" part masks off everything but the bottom three bits, which limits the number to the range 0..7 (this is the same thing as writing "% 8", but slightly more efficient). Finally I subtract three to turn the range into -3..4, which is what I actually wanted for the flame effect... -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa