rand() semantics
| From: | Soeren Staun-Pedersen | Date: | Mon, 02 Oct 2000 07:47:43 +0000 |
| Subject: | rand() semantics | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-33962@lists.php.net to get a copy of this message | ||
Hey
The other day rand() bugged at me cause I gave it to parameters namely 0
and 0. It seems that 0..0 is not a valid range. Why not? It makes
perfectly good sense mathematically and logically.
This results in horrible code like this:
$rows=mysql_numrows($res);
if ($rows>1)
$pick=mt_rand(0,$rows-1);
else
$pick=0;
Which is just plain silly IMHO. Being what I would call a religious
programmer it is not an option to set my warning level higher or introduce
@'s. This should not give a warning at all IMO.
Cheers,
Soeren Staun-Pedersen - Staun@SunSITE.auc.dk
------
"The internet is full, beat it"
- Me.