LPow correction

VLD/VMB gwyn at BRL.ARPA
Tue Jun 24 11:48:42 AEST 1986


Jim Cottrell pointed out to me that 0^0 should be 1, not 0
as I had it in my posted LPow() function.  I thought I had
a reason for making it 0, but since I'm unable to reconstruct
that line of reasoning, and *especially* since I can show
(using l'Hospital's rule) that
	limit of x^x as x->0+ is precisely 1,
I am amending our master copy of LPow() to handle exponent 0
as another special case.  Just insert
	if ( exponent == 0 )
		return 1;
in front of the other special cases.  This will make 0^n
zero for n > 0, 1 for n == 0, and 0 (should be infinite)
for n < 0.  The latter is the only known inaccuracy and is
due entirely to not wanting to clutter the algorithm with
error handling; if you want to add error handling this is
the place (recommend setting EDOM and returning MAX_LONG).



More information about the Comp.lang.c mailing list