Pollita <[EMAIL PROTECTED]> wrote:

> log(0) in any base (except 0, which would be silly) is an undefined
> number.

Yes, that's what the teachers told us before they admitted the existance
of infinity.

> the libc log() function will return an exceedingly small number
> to avoid causing widepsread panic when log(0) is attempted
> (-1.7976931348623E+308 shown below).

Are you sure?

% cat log.c
#include <stdio.h>
#include <math.h>

int main()
{
  printf("%g\n",log(0));
}

% gcc log.c -o log -lm
% ./log
-inf

That's on Linux. On Tru64, it prints:

-1.79769e+308

> The test function for log:
> 
> $x2 = (int) pow($base, log($x, $base));
> 
> attempts to check that $x2 is close to $x, but since log(0,*) will return
> an excessively small number, pow() winds up choking.
> 
> Suggest: $x2 = (int) log(pow($x,base),$base); instead.

Thanks for the suggestion, but it dumps core nevertheless:

% sapi/cli/php -r 'echo log(pow(0,2),2),"\n";'
Floating point exception (core dumped)
% sapi/cli/php -r 'echo log(0,2),"\n";'
Floating point exception (core dumped)

> P.S. example below using log in base 1 is also nonsensical... only
> log(1,1) is a valid use of log with a base parameter of 1, any other value
> results in "undefined"

Umm, yes, maybe - but my point was that PHP should not dump core in such
situations, and it certainly should not do so in a "make test" ("Wait a
minute, what's that core file here? And now you want me to 'make
install'?!").

Regards...
                Michael

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

Reply via email to