Re: RAND, SRAND Not random....

From: Date: Sun, 19 Nov 2000 09:29:00 +0000
Subject: Re: RAND, SRAND Not random....
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26113@lists.php.net to get a copy of this message
Hi there, The C library is a fairly bad random number generator. I've seen it give the same number everytime until the seed was changed. But there is ways to overcome it. Maybe try mt_rand() - http://www.php.net/manual/function.mt-rand.php The Numerial Recipes in C book (with the ubiquitous blood red hard cover) suggests: j = 1 + (int)(10.0 * rand() / (RAND_MAX + 1.0)); In PHP I guess you just have to replace 10.0 with (float)$CalSize, and rand() with rand(0, RAND_MAX). I don't know math and how numbers are handled in PHP... Jason -- Jason Murray Developer jWeb New Media Design 1 877 525 jWEB

« previous php.general (#26113) next »