Re: [PHP-DEV] New pow-function
On Tue, 03 Jul 2001, Jeroen van Wolffelaar wrote: Hi, I've rewritten the pow(base,exp) function. It is attached. In stead of a mere call to the c-lib function pow, this one actually does something more smart. This is to protect those people not knowing that there is huge difference between raising to an integer power and raising to a fractional power. It will give sensible errors rather than bogus results. It will also return integer when possible, i.e. pow(5,5) will return the INTEGER 3125. Read the new function for more info, it's richly commented, and for any questions: just mail me. IMPORTANT: I didn't test it yet, I'm not even sure there are no compile errors. (My linux machine doesn't have libtool 1.4 :-(( ) Please use proper Z_* macros, that is Z_LVAL_PP(exp) instead of Z_LVAL(*exp). -Andrei In this age, which believes that there is a short cut to everything, the greatest lesson to be learned is that the most difficult way is, in the long run, the easiest. -Henry Miller, The Books in My Life -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] New pow-function
IMPORTANT: I didn't test it yet, I'm not even sure there are no compile errors. (My linux machine doesn't have libtool 1.4 :-(( ) Hey, I can now compile :) And there is an error, so ignore this for now :( Please use proper Z_* macros, that is Z_LVAL_PP(exp) instead of Z_LVAL(*exp). Z_LVAL_P(exp) in this case, I assume? -Andrei Jeroen -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] New pow-function
On Tue, 03 Jul 2001, Jeroen van Wolffelaar wrote: IMPORTANT: I didn't test it yet, I'm not even sure there are no compile errors. (My linux machine doesn't have libtool 1.4 :-(( ) Hey, I can now compile :) And there is an error, so ignore this for now :( Please use proper Z_* macros, that is Z_LVAL_PP(exp) instead of Z_LVAL(*exp). Z_LVAL_P(exp) in this case, I assume? You use *_PP variants for ** pointers, and _P for * pointers. -Andrei Music expresses that which can not be said and on which it is impossible to be silent. -Victor Hugo -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] New pow-function
You use *_PP variants for ** pointers, and _P for * pointers. k. I've now fixed the compile problems, it will compile now. Even better: it works :-) See attachment. Greetz, Jeroen new_pow_func.c -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] New pow-function
On Tue, 03 Jul 2001, Jeroen van Wolffelaar wrote: You use *_PP variants for ** pointers, and _P for * pointers. k. I've now fixed the compile problems, it will compile now. Even better: it works :-) See attachment. And try to use ZEND_NUM_ARGS() wherever possible. Like here: zend_get_parameters_ex(ZEND_NUM_ARGS(),zbase,zexp); -Andrei What's hard, in hacking as in fiction, is not the writing, it's deciding what to write. -- Neal Stephenson -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] New pow-function
And try to use ZEND_NUM_ARGS() wherever possible. Like here: zend_get_parameters_ex(ZEND_NUM_ARGS(),zbase,zexp); I'm fairly new to C, and surely new to the php-implementation, so I took this from many, many other functions, where it was done that way... I haven't noticed any function doing it like that :-) But sure, I'll keep it in mind. Though this is faster. And pow isn't likely to change it's number of parameters :). -Andrei What's hard, in hacking as in fiction, is not the writing, it's deciding what to write. -- Neal Stephenson -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] New pow-function
On Tue, 03 Jul 2001, Jeroen van Wolffelaar wrote: And try to use ZEND_NUM_ARGS() wherever possible. Like here: zend_get_parameters_ex(ZEND_NUM_ARGS(),zbase,zexp); I'm fairly new to C, and surely new to the php-implementation, so I took this from many, many other functions, where it was done that way... I haven't noticed any function doing it like that :-) But sure, I'll keep it in mind. Though this is faster. And pow isn't likely to change it's number of parameters :). ZEND_NUM_ARGS() is a preprocessor macro that expands to the number of arguments passed to the function -- it's not any slower than specifying a constant. -Andrei If you find a job that you love, you'll never work another day in your life. - Mark Jackson -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]