php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1857 rand() produces values outside a specified range
Submitted: 1999-07-23 19:56 UTC Modified: 1999-07-23 22:31 UTC
From: andrew at walcat dot ac dot uk Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Beta 1 OS: RH6
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andrew at walcat dot ac dot uk
New email:
PHP Version: OS:

 

 [1999-07-23 19:56 UTC] andrew at walcat dot ac dot uk
Hello,

This error seems to be exactly like the one present in 3.0.6, rand() generates values outside the given range. I have run the following code many times and get numbers well above 122, and numbers below 97 too.

<?
srand((double)microtime()*1000000);
$rand = rand(97,122);
echo($rand);
?>

Regards,
Andy Pitt.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-07-23 22:31 UTC] rasmus at cvs dot php dot net
Fixed in CVS
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 08:00:02 2026 UTC