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

('binary' encoding is not supported, stored as-is) 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 <email protected>> schrieb am 10.11.2000 um 20:54:

> ID: 7281
> Updated by: hholzgra
> Reported By: a.schommer <email protected>
> 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 <email protected>
> 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
>

 

-- 
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>