php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8293 rand function failure
Submitted: 2000-12-16 10:20 UTC Modified: 2000-12-18 06:00 UTC
From: edasx at worldoffreegames dot com Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0.3pl1 OS: Win32 - Win98SE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: edasx at worldoffreegames dot com
New email:
PHP Version: OS:

 

 [2000-12-16 10:20 UTC] edasx at worldoffreegames dot com
srand((double)microtime()*1000000);
$rndnum = rand(1, 100000);

this fails, with invalid range error.

the range of
$rndnum = rand(1, 32530);
does not fail and around 34000 fails, so there's probably incorrect type (integer) that's too small.





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-18 06:00 UTC] hholzgra@php.net
the maximum range for rand() is platform-dependant,
use getrandmax() to see what it is for your system

or use mt_rand() if you want to have platform independant
randomness
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 08:01:29 2024 UTC