PHP 4.0 Bug #7281 Updated: rand() gives range warnings over 15 bits
| From: | hholzgra@php.net | Date: | Fri, 10 Nov 2000 19:54:35 +0000 |
| Subject: | PHP 4.0 Bug #7281 Updated: rand() gives range warnings over 15 bits | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-37712@lists.php.net to get a copy of this message | ||
ID: 7281
Updated by: hholzgra
Reported By: a.schommer@dialogmedien.de
Status: Closed
Bug Type: Math related
Assigned To:
Comments:
this is system dependant , on Solaris 2.7 you have
./stdlib.h:#define RAND_MAX 32767
so that's it
you can always use the PHP function getrandmax()
to find out the max. difference between the min and max
parameters for your system
Previous Comments:
---------------------------------------------------------------------------
[2000-10-17 11:26:31] a.schommer@dialogmedien.de
rand() should work on int, which is about 2 billion. But i get
Warning: rand(): Invalid range: 1000000..1032768 in /tmp/apa2/htdocs/admin/tst.php3 on line 1
For this code:
<? print rand (1000000, 1032768); ?>
(a result is given anyway)
Not the size, but the difference seems to matter: If it exceeds 2^15-1, the warning comes up:
<? print rand (1000000, 1032767); ?>
produces only a result
sizeof(int) really is 4.
So i don't think it's my fault.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7281