Re: php4 /ext/standard rand.c
| From: | Jeroen van Wolffelaar | Date: | Sat, 08 Sep 2001 16:39:52 +0000 |
| Subject: | Re: php4 /ext/standard rand.c | ||
| References: | 1 | Groups: | php.cvs php.dev |
| Request: | Send a blank email to php-dev+get-65488@lists.php.net to get a copy of this message | ||
> sterling Wed Sep 5 16:52:45 2001 EDT
>
> Modified files:
> /php4/ext/standard rand.c
> Log:
> a bit of api cleanup... move range stuff into a macro (properly :)
Yeah yeah... I know by now...
> +#define RAND_RANGE(__n, __min, __max) \
> + (__min) + (int)((double)(__max) - (__min) + 1.0) * ((__n) /
(PHP_RAND_MAX + 1.0))
> +
[in PHP_FUNCTION(rand)]
> + number = RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max));
> }
[in PHP_FUNCTION(mt_rand)]
> + number = RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max));
> }
PHP_RAND_MAX is only valid for rand, not for mt_rand. mt_rand has
MT_RAND_MAX, which
could be different (not on most common builds, but on some platforms it is).
--Jeroen