Mail Archives: djgpp/1996/08/12/20:00:29
Francois Charton <deef AT pobox DOT oleane DOT com> wrote:
: While I'm at it, I looked yesterday at the code for rand(), found the
: "classical" ANSI linear congruential generator with a small change :
: there is some kind of "bit shuffling" of the result:
: next = (next<<15) ^ (next >> 27);
: Are you sure that this doesn't degrade the randomness of the generator ?
: If I remember well, higher bits in such generators are more random than
: lower bits, and the shuffling is more or less an "exchange" between
: higher and lower bits.
Actually, when you want randomness, the rand function isn't of much
use anyway. (I think this is even mentioned in some versions of the
rand(3) manpage). There are a couple of much improved random
functions, including one from BSD, which may or may not be in the
djgpp library (random(), I think) or you could get it from the BSD 4.4
distribution.
bye, Alexander
--
Alexander Lehmann, | "On the Internet,
alex AT hal DOT rhein-main DOT de (plain, MIME, NeXT) | nobody knows
lehmann AT mathematik DOT th-darmstadt DOT de (plain) | you're a dog."
<URL:http://www.mathematik.th-darmstadt.de/~lehmann/>
- Raw text -