Mail Archives: djgpp/1998/02/17/10:43:36
Demandred wrote:
> Hmmm... random() returns a random (duh) integer that can be pretty
> huge (0 to MAXINT, IIRC), so I'd guess that the & 7 (bitwise AND with
> 111b) acts like a % 8 (modulus 8)(??). Why, I don't know... maybe
> bitwise AND is faster than mod?
x%n is the same as x&(n - 1), when n is a power of 2.
Bitwise operations are much, much faster than integer division operators
(/, %).
--
Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
Alcyone Systems / http://www.alcyone.com/max/
San Jose, California, United States / icbm://+37.20.07/-121.53.38
\
"Life may be / the product of imperfections."
/ (Marclo Gleiser)
- Raw text -