Yasuo Ohgaki wrote:
> 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?

Commited by myself

--
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;
>> }
>> /* }}} */
>>
>>
> 
> ------------------------------------------------------------------------
> 
> Index: basic_functions.c
> ===================================================================
> RCS file: /repository/php4/ext/standard/basic_functions.c,v
> retrieving revision 1.442
> diff -u -r1.442 basic_functions.c
> --- basic_functions.c 10 Feb 2002 17:38:15 -0000      1.442
> +++ basic_functions.c 21 Feb 2002 07:58:36 -0000
> @@ -475,6 +475,7 @@
>       PHP_FE(dechex,                                                                 
>                                                 NULL)
>       PHP_FE(base_convert,                                                           
>                                         NULL)
>       PHP_FE(number_format,                                                          
>                                         NULL)
> +     PHP_FE(fmod,                                                                   
>                                                 NULL)
>       PHP_FE(ip2long,                                                                
>                                                 NULL)
>       PHP_FE(long2ip,                                                                
>                                                 NULL)
>  
> Index: math.c
> ===================================================================
> RCS file: /repository/php4/ext/standard/math.c,v
> retrieving revision 1.77
> diff -u -r1.77 math.c
> --- math.c    28 Jan 2002 16:06:27 -0000      1.77
> +++ math.c    21 Feb 2002 07:58:37 -0000
> @@ -1046,6 +1046,21 @@
>  }
>  /* }}} */
>  
> +/* {{{ proto double fmod(double x, double y)
> +   Returns the remainder of dividing x by y as a double */
> +PHP_FUNCTION(fmod)
> +{
> +     double num1, num2;
> +
> +     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd",  &num1, &num2) == 
>FAILURE) {
> +             return;
> +     }
> +     
> +     Z_DVAL_P(return_value) = fmod(num1, num2);
> +     Z_TYPE_P(return_value) = IS_DOUBLE;
> +}
> +/* }}} */
> +
>  /*
>   * Local variables:
>   * tab-width: 4
> Index: php_math.h
> ===================================================================
> RCS file: /repository/php4/ext/standard/php_math.h,v
> retrieving revision 1.14
> diff -u -r1.14 php_math.h
> --- php_math.h        9 Jan 2002 23:59:04 -0000       1.14
> +++ php_math.h        21 Feb 2002 07:58:37 -0000
> @@ -58,6 +58,7 @@
>  PHP_FUNCTION(octdec);
>  PHP_FUNCTION(base_convert);
>  PHP_FUNCTION(number_format);
> +PHP_FUNCTION(fmod);
>  PHP_FUNCTION(deg2rad);
>  PHP_FUNCTION(rad2deg);
> 
> 


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to