# Why 0^0 = 1?

**URL:** <https://discourse.julialang.org/t/why-0-0-1/6889>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 4, 2017, 11:28pm UTC](https://discourse.julialang.org/t/why-0-0-1/6889 "2017-11-04T23:28:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [November 4, 2017, 11:28pm UTC](https://discourse.julialang.org/t/why-0-0-1/6889/1 "2017-11-04T23:28:12Z")

</div>

0^0 is defined in Julia, and equals 1. Mathematically 0^0 is undefined.I think other programming languages leave it undefined, although Python sets 0^0 = 0 (which is insane in my opinion).

To me it makes sense to make 0^0 = 1 (it turns out to be useful in some code I am writing right now, preventing some `if`s and making things easier).

But I was wondering what other people think about this. Why was this approach selected in Julia?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 4, 2017, 11:49pm UTC](https://discourse.julialang.org/t/why-0-0-1/6889/2 "2017-11-04T23:49:30Z")

</div>

> [@e3c6](#):
>
> 0^0 is defined in Julia, and equals 1. Mathematically 0^0 is undefined.

Yes but there are some reasons to take 1 as value:

- [https://www.math.hmc.edu/funfacts/ffiles/10005.3-5.shtml](https://www.math.hmc.edu/funfacts/ffiles/10005.3-5.shtml)
- [algebra precalculus - Zero to the zero power – is $0^0=1$? - Mathematics Stack Exchange](https://math.stackexchange.com/q/11150/80474)
- [http://www.askamathematician.com/2010/12/q-what-does-00-zero-raised-to-the-zeroth-power-equal-why-do-mathematicians-and-high-school-teachers-disagree/](http://www.askamathematician.com/2010/12/q-what-does-00-zero-raised-to-the-zeroth-power-equal-why-do-mathematicians-and-high-school-teachers-disagree/)

> [@e3c6](#):
>
> I think other programming languages leave it undefined, although Python sets 0^0 = 0 (which is insane in my opinion).

No, in Python 0 raised to power 0 is 1:

```python
>>> 0**0
1

```

> [@e3c6](#):
>
> Why was this approach selected in Julia?

Look to the code in `base/intfuncs.jl`. Basically, if the exponent is 0 the returned value is always 1.

---

<div class="post-metadata">

**Author:** ![PabloZubieta](https://avatars.discourse-cdn.com/v4/letter/p/ee7513/32.png) [@PabloZubieta](https://discourse.julialang.org/u/PabloZubieta)\
**Post date:** [November 5, 2017, 10:33pm UTC](https://discourse.julialang.org/t/why-0-0-1/6889/3 "2017-11-05T22:33:38Z")

</div>

Just as an additional curious note, here’s a nice reference where Knuth argues why `0^0` should be `1`:

> **[9205211.pdf](https://arxiv.org/pdf/math/9205211.pdf)**
>
> 201.42 KB
