Re: PHP 4.0 Bug #7281 Updated: rand() gives range warnings over 15 bits

From: Date: Wed, 15 Nov 2000 12:08:51 +0000
Subject: Re: 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-38133@lists.php.net to get a copy of this message
Hello, Your comment are plausible, but there are some strange points: 1It changed (somewhere between php 3.0.13 and 4.0.2): With php3 And i did not change stdlib.h. 2 This is not documented with the function rand() 3) There is a result and it seems to be a random number [4), but this may be irrelevant, the whole problem does not apply to mt_rand()] Bug Database <php-dev@lists.php.net> schrieb am 10.11.2000 um 20:54: > 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 >

« previous php.dev (#38133) next »