[PHP-DEV] PHP 4.0 Bug #7281: rand() gives range warnings over 15 bits From: a.schommer <email protected>
Date: 10/17/00

From: a.schommer <email protected>
Operating system: Solaris 2.7
PHP version: 4.0.2
PHP Bug Type: Math related
Bug description: rand() gives range warnings over 15 bits

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.

-- 
Edit Bug report at: http://bugs.php.net/?id=7281&edit=1

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>