cvs: php4 /ext/standard php_rand.h rand.c

From: Date: Sun, 09 Jun 2002 04:26:37 +0000
Subject: cvs: php4 /ext/standard php_rand.h rand.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12264@lists.php.net to get a copy of this message
andrei Sun Jun 9 00:26:37 2002 EDT Modified files: /php4/ext/standard rand.c php_rand.h Log: Make RAND_RANGE() an API macro. Index: php4/ext/standard/rand.c diff -u php4/ext/standard/rand.c:1.58 php4/ext/standard/rand.c:1.59 --- php4/ext/standard/rand.c:1.58 Thu Feb 28 03:26:48 2002 +++ php4/ext/standard/rand.c Sun Jun 9 00:26:36 2002 @@ -20,7 +20,7 @@ | Based on code from: Shawn Cokus <Cokus@math.washington.edu> | +----------------------------------------------------------------------+ */ -/* $Id: rand.c,v 1.58 2002/02/28 08:26:48 sebastian Exp $ */ +/* $Id: rand.c,v 1.59 2002/06/09 04:26:36 andrei Exp $ */ #include <stdlib.h> @@ -315,8 +315,6 @@ * * -RL */ -#define RAND_RANGE(__n, __min, __max, __tmax) \ - (__n) = (__min) + (long) ((double) ((__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0))) /* {{{ proto int rand([int min, int max]) Returns a random number */ Index: php4/ext/standard/php_rand.h diff -u php4/ext/standard/php_rand.h:1.18 php4/ext/standard/php_rand.h:1.19 --- php4/ext/standard/php_rand.h:1.18 Thu Feb 28 03:26:48 2002 +++ php4/ext/standard/php_rand.h Sun Jun 9 00:26:36 2002 @@ -20,7 +20,7 @@ | Based on code from: Shawn Cokus <Cokus@math.washington.edu> | +----------------------------------------------------------------------+ */ -/* $Id: php_rand.h,v 1.18 2002/02/28 08:26:48 sebastian Exp $ */ +/* $Id: php_rand.h,v 1.19 2002/06/09 04:26:36 andrei Exp $ */ #ifndef PHP_RAND_H #define PHP_RAND_H @@ -38,6 +38,9 @@ #else #define PHP_RAND_MAX RAND_MAX #endif + +#define RAND_RANGE(__n, __min, __max, __tmax) \ + (__n) = (__min) + (long) ((double) ((__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0))) /* MT Rand */ #define PHP_MT_RAND_MAX ((long) (0x7FFFFFFF)) /* (1<<31) - 1 */

« previous php.cvs (#12264) next »