Last modified: 2006-12-11 21:09:59 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 8121 - wfRandom() is not between 0 and 1
wfRandom() is not between 0 and 1
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal trivial (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-12-02 16:02 UTC by Lejonel
Modified: 2006-12-11 21:09 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Lejonel 2006-12-02 16:02:13 UTC
wfRandom returns a value greater than 1 with a probability of ~2^-31 (if
mt_getrandmax == 2^31-1). I don't think that will cause any problems, but a
comment in the code says the value should be between 0 and 1.

Here is a "correct" version of the function:

function wfRandom() {
    # The maximum random value is "only" 2^31-1, so get two random
    # values to reduce the chance of dupes
    $max = mt_getrandmax() + 1;
    $rand = number_format( (mt_rand() * $max + mt_rand())
        / $max / $max, 12, '.', '' );
    return $rand;
}
Comment 1 Antoine "hashar" Musso (WMF) 2006-12-11 21:09:59 UTC
Fixed in r18271

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links