Mail Archives: djgpp/1998/02/09/18:32:59
On Mon, 09 Feb 1998 13:18:12 -0800 in comp.os.msdos.djgpp Dan
<dyoon AT home DOT com> wrote:
: hotspot[c] += (random() & 7) - 3;
: what does "random() & 7" do? i'm figuring random() returns a random
: # of type int maybe? but i have no idea what the "& 7" does. the & 7
: is the only thing that i need an explenation for. any help would be
: much appreciated.
`&' is the bitwise AND operator. If you don't know what this means, I
suggest you read about boolean operators in a C book.
In this case, `random' returns an integer. ANDing this with 7 results
in a number from 0 to 7; subtracting three gives a number from -3 to 4.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
ko tavla fo la lojban
- Raw text -