__builtin_cpow((0,0),(0,0))
Duncan Sands
baldrick@free.fr
Wed Mar 9 11:47:00 GMT 2005
> On the one hand, as said above, there is no way of defining 0^0
> using continuity, but on the other hand, many important properties
> remain satisfied if we choose 0^0 = 1 (which is frequently
> adopted, as a convention, by mathematicians). Kahan suggests to
> choose 0^0 = 1. [...]
The problem is x^0.0 (real exponent), not x^0 (integer exponent).
0^0 (integer exponent) *can* be defined by continuity, the value is 1.
The fact that it is defined by continuity is exactly the reason 0^0=1
is useful in contexts where the exponent is an integer (polynomials
etc): the special case 0^0 acts the same as the general case x^0,
since it is the limiting value of it. In my experience, defining 0^0.0
(real exponent) to be 1.0 is much less useful. Now in practice I can
imagine that a language confuses x^integer and x^real by mapping them
to the same function, or only provides a function for doing x^real.
Perhaps this is the case with C? If so, then having 0^0.0 return 1.0
is a convenient hack to work around that mistake. On the other hand,
ignoring such things as language standards and the weight of history,
if there are separate functions for x^integer and x^real, then in my
opinion the most sensible thing would be for 0^0 to return 1, and
0^0.0 to return NaN. This might confuse programmers though.
All the best,
Duncan.
More information about the Gcc
mailing list