(0011505)

nicolas cellier

120107 18:06


Note:
i checked what does C (libm.so.6) in these cases:
pow(negativeZero,zero) > 1.0
correct
pow(0.0,0.0) > 1.0
questionable could as well answer NaN or raise exception
possible rationale: pow(1.0/exp(100.0),0.0) will answer 1.0
so does pow(+1.0/exp(100.0),0.0) (there is no Float positiveZero)
pow(zero,negativeZero) > 1.0
could as well be a division by zero
pow(negativeZero,0.5) > 0.0
could as well be NaN (a negative number raised to non integer power)
pow(negativeZero,1.0) > 0.0
correct
pow(nan,0.0) > 1.0
possibly a bug of libm. Squeak does the same
pow(0.0,nan) > nan
Here squeak does answer zero...
pow(0.0,inf) > 0.0
questionable could as well be nan
pow(inf,0.0) > 1.0
questionable could as well be nan
Note that libm pow seems to also handle raisedToInteger: case...
patch.1.cs does not exactly the same for negativeZero, so I upload patch.2.cs
but this raise a lot of questions when pushing IEEE 754 logic to the borders...
what is really in the standard anyway?
#include <math.h>
#include <stdio.h>
int main() {
double nz=1.0/exp(1.0e100);
double nan=0.0/0.0;
double inf=exp(100.0);
printf("1.0/0.0=%f\n",1.0/nz);
printf("pow(0.0,0.0)=%f\n",pow(0.0,0.0));
printf("pow(0.0,0.0)=%f\n",pow(0.0,nz));
printf("pow(0.0,0.0)=%f\n",pow(nz,0.0));
printf("pow(0.0,0.5)=%f\n",pow(nz,0.5));
printf("pow(0.0,1.0)=%f\n",pow(nz,1.0));
printf("pow(1.0,0.5)=%f\n",pow(1.0,0.5));
printf("pow(nan,0.0)=%f\n",pow(nan,0.0));
printf("pow(0.0,nan)=%f\n",pow(0.0,nan));
printf("pow(0.0,1.0)=%f\n",pow(0.0,1.0));
printf("pow(0.0,1.0)=%f\n",pow(nz,1.0));
printf("pow(0.0,inf)=%f\n",pow(0.0,inf));
printf("pow(0.0,inf)=%f\n",pow(0.0,inf));
printf("pow(inf,0.0)=%f\n",pow(inf,0.0));
printf("pow(inf,0.0)=%f\n",pow(inf,0.0));
return 0;
}

