#40724 [NEW]: srand returns different results in 5.2.1 than in previous versions

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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....
    4. 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...
    5. Deleting previous versions of Photoshop
      I just upgraded to 7.0; do I delete 6.0 now?
  3. #2

    Default #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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139