Re: fmod() function
| From: | Yasuo Ohgaki | Date: | Thu, 21 Feb 2002 08:12:04 +0000 |
| Subject: | Re: fmod() function | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-80237@lists.php.net to get a copy of this message | ||
If you could send patch as unified diff, it's much easier to apply :)
Anyway, I attached hand edited diff since my CVS source contains
other changes now...
Someone care to check in?
--
Yasuo Ohgaki
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;
> }
> /* }}} */
>
>