Is it a bug?
No, a bug is something that violates the specification. The specification states:
Returns the value of the first argument raised to the power of the second argument. Special cases:
- If the second argument is positive or negative zero, then the result is 1.0.
Finally, mathematically, some do define 0^0
as 1
. In fact, Knuth says that it has to be 1
.
The number of mappings from the empty set to the empty set is 0^0
. It has to be 1
.
His reasoning is as follows. If you have two sets, A
and B
, the number of functions from A
to B
is |B|^|A|
. How many functions are there from the empty set to the empty set? Well, there is exactly one. By this logic, 0^0
should be 1
.