Re: fmod() function
| From: | Andi Gutmans | Date: | Thu, 21 Feb 2002 06:07:32 +0000 |
| Subject: | Re: fmod() function | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-80234@lists.php.net to get a copy of this message | ||
You can do $a % $b to calculate the remainder.
Andi
At 12:59 PM 2/21/2002 +1100, Graeme Merrall wrote:
I was porting some Python scripts to PHP and came across the fmod() function. Since it's not implemented in PHP so I whipped up an fmod function for inclusion into ext/standard/math.c which I've pasted below. I can create a diff if necessary to include the 2 small changes to basic_functions.c and php_math.h Cheers, Graeme /* {{{ proto double fmod(double x, double y) Returns the remainder of dividing x by y as a double */ PHP_FUNCTION(fmod) {zval **num1, **num2; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &num1, &num2)== FAILURE) {WRONG_PARAM_COUNT; }convert_to_double_ex(num1); convert_to_double_ex(num2); Z_DVAL_P(return_value) = fmod(Z_DVAL_PP(num1), Z_DVAL_PP(num2)); Z_TYPE_P(return_value) = IS_DOUBLE;} /* }}} */ -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php