On Sun, Feb 02, 2003 at 01:11:06 -0800, Kris Kennaway wrote: > > Another problem (noticed by tjr) is that once the sequence hits '0' it > jumps to INT_MAX and stays there forever. For example, seeding with > srand(0) produces nothing but INT_MAX from rand(). > > It looks like a lot more validation of this PRNG is needed.
As I see searching through various sources, this is not simple overlook but fundamental feature of this formulae - it can't be initialized with zero and BSD developers try to deal with that fact by simple adding of INT_MAX in zero case (which is not in the original formulae), but gain nothing this way. Workaround I find so far is something like that #define MASK 123459876 seed ^= MASK; ... calculate value ... seed ^= MASK; Which just add another magick value, but fix zero. I am still searching... -- Andrey A. Chernov http://ache.pp.ru/
msg51498/pgp00000.pgp
Description: PGP signature