Edit report at https://bugs.php.net/bug.php?id=60786&edit=1

 ID:                 60786
 Updated by:         ras...@php.net
 Reported by:        jazzerman at gmail dot com
 Summary:            Force seeding to srand different numbers still gives
                     the same random number
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            *General Issues
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Yes, no bug here. There are plenty of seeds that lead to the same initial 
random 
number. You will notice, however, that the second number in the sequence is 
different across the 2 seeds.


Previous Comments:
------------------------------------------------------------------------
[2012-01-18 06:17:05] phpmpan at mpan dot pl

With 5.3.9 on Arch64 I'm getting 266557046 in both cases. Pair 53923 and 40348 
causes the same bahaviour. And I believe there are many more. But none of this 
cases indicate a problem. It's normal that values are repeating in sequences.

------------------------------------------------------------------------
[2012-01-18 05:53:28] anon at anon dot anon

I get this:

898434
822276816
351663
561490788

(Windows/PHP 5.3.2)

------------------------------------------------------------------------
[2012-01-18 03:29:13] phpmpan at mpan dot pl

I see no reason to assume that two pseudorandom sequences don't contain common 
values. "Random" doesn't mean that values in a single sequence or a set of 
sequences can't repeat. In fact it's perfectly normal and expected that the do 
share some elements. Othwerwise they would not be pseudorandom anymore.

I must admit, however, that you're quite lucky guy. Finding by accident two 
different sequences that share a common element at the same position and, 
what's more interesting, it is the first element. What made you selecting 
822276816 and 561490788 as the seeds?

------------------------------------------------------------------------
[2012-01-17 23:06:36] jazzerman at gmail dot com

Description:
------------
srand( 822276816 );
$a = rand(123456, 987654);
echo $a;
echo "\n";
echo '822276816';
echo "\n";

srand( 561490788 );
$a = rand(123456, 987654);
echo $a;
echo "\n";
echo '561490788';
echo "\n";

Test script:
---------------
<?php 

srand( 822276816 );
$a = rand(123456, 987654);
echo $a;
echo "\n";
echo '822276816';
echo "\n";

srand( 561490788 );
$a = rand(123456, 987654);
echo $a;
echo "\n";
echo '561490788';
echo "\n";

?>

Expected result:
----------------
Since I'm seeding to srand different integers, it should echo two different 
random numbers.

Actual result:
--------------
It echos the same numbers even when seeding to srand two different integers


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60786&edit=1

Reply via email to