
On 2009 Feb 27, at 1:50, Ketil Malde wrote:
Lennart Augustsson
writes: C's rand() function is very bad and should never be used really.
On Linux (really GNU libc, I suppose) it is the same as random(). But for portability, one is encouraged to spend the two extra letters. I don't understand the details, but I think the Mersenne twister is much better in any case.
Yes, much better than any LC PRNG including rand(), random(), and the System V/POSIX lrand48() family. That said, Linux making rand() == random() breaks portability in the case where you want a repeatable stream for testing purposes; as usual, Linux chucks portability out the window at any opportunity. (Sadly, POSIX permits this because of POSIX implementations for non-Unix hosts, although it does include a fixed-behavior PRNG as documentation for this case.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH