Ask a Question related to PHP Bugs, Design and Development.
-
dave at dmorg dot org #1
#40724 [NEW]: srand returns different results in 5.2.1 than in previous versions
From: dave at dmorg dot org
Operating system: linux, windows
PHP version: 5.2.1
PHP Bug Type: Math related
Bug description: srand returns different results in 5.2.1 than in previous versions
Description:
------------
I use srand to seed random numbers with student id numbers so that
whenever students relog in to an assignment, their questions have the same
input values and they can continue where they left off.
I am now getting different results than before. I'm not sure whether this
is an unintended consequence of some apparently unrelated code change or
whether it is intended.
Reproduce code:
---------------
<?php
mt_srand(42);
echo mt_rand();
?>
produces 1387371436 under 4.*, 5.1.1. 5.1.4
produces 1354439493 under 5.2.1
Expected result:
----------------
I would expect results from the random number generator to be consistent
when seeded with the same number
Actual result:
--------------
produces 1387371436 under 4.*, 5.1.1. 5.1.4
produces 1354439493 under 5.2.1
--
Edit bug report at [url]http://bugs.php.net/?id=40724&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40724&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40724&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40724&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40724&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40724&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40724&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40724&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40724&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40724&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40724&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40724&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40724&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40724&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40724&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40724&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40724&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40724&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40724&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40724&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40724&r=mysqlcfg[/url]
dave at dmorg dot org Guest
-
Uninstalling Previous Versions
I have just installed the newest version of Flash Player 9.x and still have a previous version of Macromedia Flash Player 6.x and Adobe Flash Player... -
Query results don't display properly in results table.IGNORE PREVIOUS
:disgust; I need to display the results of a query. The query runs properly. My problem is having specific results display in specific locations in... -
Saving for Previous Versions of Director
I have only done it once before, and now have gone crazy. Does anyone know how to save a Director MX movie for Director 8 or previous versions.... -
How can you open CS files with previous versions?
I already have a brand new Illustrator CS in my company. However, everytime we make a new file with this version, all other previous versions of... -
Deleting previous versions of Photoshop
I just upgraded to 7.0; do I delete 6.0 now? -
iliaa@php.net #2
#40724 [Opn->Bgs]: srand returns different results in 5.2.1 than in previous versions
ID: 40724
Updated by: [email]iliaa@php.net[/email]
Reported By: dave at dmorg dot org
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: linux, windows
PHP Version: 5.2.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
[url]http://www.php.net/manual/[/url] and the instructions on how to report
a bug at [url]http://bugs.php.net/how-to-report.php[/url]
Random numbers are random, so you can't expect to get the same number
out of a random number generator.
Previous Comments:
------------------------------------------------------------------------
[2007-03-05 07:52:38] dave at dmorg dot org
Description:
------------
I use srand to seed random numbers with student id numbers so that
whenever students relog in to an assignment, their questions have the
same input values and they can continue where they left off.
I am now getting different results than before. I'm not sure whether
this is an unintended consequence of some apparently unrelated code
change or whether it is intended.
Reproduce code:
---------------
<?php
mt_srand(42);
echo mt_rand();
?>
produces 1387371436 under 4.*, 5.1.1. 5.1.4
produces 1354439493 under 5.2.1
Expected result:
----------------
I would expect results from the random number generator to be
consistent when seeded with the same number
Actual result:
--------------
produces 1387371436 under 4.*, 5.1.1. 5.1.4
produces 1354439493 under 5.2.1
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40724&edit=1[/url]
iliaa@php.net Guest



Reply With Quote

