www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/10/00:01:23

Newsgroups: comp.os.msdos.djgpp
From: tob AT world DOT std DOT com
Subject: Re: Allegro ex11.c
Message-ID: <Eo5BG1.F29@world.std.com>
Sender: tob AT world DOT std DOT com (Tom Breton)
Reply-To: tob AT world DOT std DOT com
Organization: BREnterprises
References: <34DF7294 DOT 21D0 AT home DOT com>
Date: Tue, 10 Feb 1998 04:36:01 GMT
Lines: 16
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Dan <dyoon AT home DOT com> writes:
>       hotspot[c] += (random() & 7) - 3;
>
> what does "random() & 7" do?

Strips out all but the lowest 3 bits. The idiom is familiar to most C
and C++ programmers. It might have been more transparently written:

        hotspot[c] += (random() % 8) - 3;

        Tom

--
When you see a spam, just remember that a spammer is some fool who just
can't believe that if they bother a million people, they'll get fewer
than a dozen interested responses. (Copy this so more wannabe spammers see it)

- Raw text -


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