about mt_srand() function

From: Date: Fri, 18 Mar 2005 18:42:42 +0000
Subject: about mt_srand() function
Groups: php.internals 
Request: Send a blank email to internals+get-15490@lists.php.net to get a copy of this message
mt_srand() is used to seed initialisation vector (IV) for Mersenne Twister pseudorandom generator. But there is a "little" problem: the actual length of IV is 19968 bits, but mt_srand() accepts only 32-bit integers, which even reduced to 31 bit in function php_mt_srand() at /ext/standard/rand.c at string: php_uint32 x = (seed | 1U) & 0xFFFFFFFFU hint: lower bit of x is always equal to 1. So, entorpy of current implementation of MT generator is 31 bit (i.e. it can generate only 2^31-1 = 2147483647 different sequences), while its potential entropy is significant higher - up 19937 bit (it is impossible to imagine the number of different sequences 2^19937-1). So, I think, it will be good idea to change mt_srand() function in that way to accept not only one integer, but array of integers with length up to 624 elements to use Mersenne Twister generator in a full power. This change do not break backward compatibility. I can make nesessary changes and post unified diff, if you agree with me. -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

« previous php.internals (#15490) next »