cvs: php4 /ext/standard rand.c

From: Date: Wed, 05 Sep 2001 20:59:24 +0000
Subject: cvs: php4 /ext/standard rand.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-7227@lists.php.net to get a copy of this message
sterling Wed Sep 5 16:59:24 2001 EDT Modified files: /php4/ext/standard rand.c Log: change range macro semantics # Kinda torn between the two, thoughts? Index: php4/ext/standard/rand.c diff -u php4/ext/standard/rand.c:1.40 php4/ext/standard/rand.c:1.41 --- php4/ext/standard/rand.c:1.40 Wed Sep 5 16:56:15 2001 +++ php4/ext/standard/rand.c Wed Sep 5 16:59:24 2001 @@ -19,7 +19,7 @@ | Based on code from: Shawn Cokus <Cokus@math.washington.edu> | +----------------------------------------------------------------------+ */ -/* $Id: rand.c,v 1.40 2001/09/05 20:56:15 sterling Exp $ */ +/* $Id: rand.c,v 1.41 2001/09/05 20:59:24 sterling Exp $ */ #include <stdlib.h> @@ -249,7 +249,7 @@ * -RL */ #define RAND_RANGE(__n, __min, __max) \ - (__min) + (int)((double)(__max) - (__min) + 1.0) * ((__n) / (PHP_RAND_MAX + 1.0)) + (__n) = (__min) + (int)((double)(__max) - (__min) + 1.0) * ((__n) / (PHP_RAND_MAX + 1.0)) /* {{{ proto int rand([int min, int max]) Returns a random number */ @@ -267,7 +267,7 @@ number = php_rand(); if (argc == 2) { - number = RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max)); + RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max)); } RETURN_LONG(number); @@ -298,7 +298,7 @@ */ number = (long) (randomMT(TSRMLS_C) >> 1); if (argc == 2) { - number = RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max)); + RAND_RANGE(number, Z_LVAL_PP(min), Z_LVAL_PP(max)); } RETURN_LONG(number);

« previous php.cvs (#7227) next »