> derick Sun Dec 16 05:59:20 2001 EDT
>
> Modified files:
> /php4/ext/standard math.c
> Log:
> - Fix for bug #14544, bogus warning in pow()
Excuse me for disturbing, but it's actually wrong now. You cannot take the
logarithm of zero. As a consequence, in exponential ways of doing pow()
(i.e. with floating-point exponent) you MUST have a positive (implying
non-zero) base.
However, with a positive exponent, it is possible to determine the limit
base->0 of e^(log(base) * exp), which equals zero. You can argue wether or
not pow() should yield zero in this case, but as people expect pow(x,0.5) to
behave like sqrt(x), I agree it'd be better to yield zero.
In concreto:
Up until revision 1.66:
pow(x, y) [x<0] => warning about nonpositive exponent
pow(0, y) [y<=0] => warning about nonpositive exponent
pow(0, y) [y>0] => warning
Revision 1.67:
pow(x, y) [x<0] => warning about nonpositive exponent
pow(0, y) [y<=0] => INF/NAN without warning
pow(0, y) [y>0] => 0.0 (because exp(NEG_INF) returns 0.0)
I suggest:
pow(x, y) [x<0] => warning about negative exponent
pow(0, y) [y<=0] => different warning ("pow(0, y) is undefined")
pow(0, y) [y>0] => 0.0
[begin pseudo-diff]
+ if (Z_DVAL_PP(zbase) == 0.0) {
+ if (Z_DVAL_PP(zexp) > 0) {
+ RETURN_DOUBLE(0.0);
+ } else {
+ warning
+ }
+ }
if (Z_DVAL_PP(zbase) < 0.0) { /* can remain like it is now after all */
:s/nonpostive/negative
[end pseudo-diff]
As for the bug, it is wrong to think that abs always yields a positive
value. abs returns a nonnegative value. So the warning DID correspond to the
case, this issue was that in this particular case it is possible to return a
decent result, even though base is nonpositive and exponent is broken
(=floating point).
> #- I think I do not need to tell who screwed this up....
Why are you so hatefull?
Regards,
--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]