[thelist] srand in php

noah noah at tookish.net
Tue Oct 23 17:11:02 CDT 2001


At 05:53 PM 23/10/2001, Andrew Forsberg wrote:
>>I'm just wondering if anyone can offer any insight on why the random 
>>number always begins with 1. The next nine digits appear to be random, 
>>but the 40 times or so that I've run this, the first digit has always been 1.
>
>The maximum random number my environment can generate (with mt_ or 
>standard random number generation) is 2147483647. Perhaps yours is lower, 
>which would explain why you aren't getting anything with a leftmost digit of 2.

Thanks for that - I ran the code you suggested and I also got 2147483647 (I 
guess it was just by chance that the numbers I was getting all happened to 
be <2000000000).

>I'm not quite sure what to suggest, except perhaps: generate two 5 digit 
>random numbers, multiply the first 5 digit number by 100,000, then add the 
>second 5 digit number to it.

Thanks - I don't really need more than 9 random digits at this point (I was 
just curious as to why the first digit of a 10 digit number was always 1), 
but I'll keep that in mind for the future.

Thanks again,
Noah





More information about the thelist mailing list