python - 为什么 0 ** 0 在 python 中等于 1

标签 python math

为什么 0 ** 0 在 Python 中等于 1?它不应该像 0/0 那样抛出异常吗?

最佳答案

维基百科对 history and the differing points of view on 有有趣的报道。 0 ** 0的值:

The debate has been going on at least since the early 19th century. At that time, most mathematicians agreed that 0 ** 0 = 1, until in 1821 Cauchy listed 0 ** 0 along with expressions like 0⁄0 in a table of undefined forms. In the 1830s Libri published an unconvincing argument for 0 ** 0 = 1, and Möbius sided with him...

应用于计算机时,IEEE 754推荐了几个计算幂的函数。它将 pow(0, 0)pown(0, 0) 定义为返回 1powr(0, 0) 作为返回 NaN

大多数编程语言都遵循 0 ** 0 == 1 的约定。对于整数和浮点参数,Python 也不异常(exception)。

关于python - 为什么 0 ** 0 在 python 中等于 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14414430/

相关文章:

jquery - setInterval() 的 Math.round() 和 Math.floor() 问题

python - Tkinter,调用 "wm_iconbitmap"和 "resizable"后闪烁窗口

math - 如何在 3d 空间中的平面上投影平面多边形

C - 使用 pow 函数求负数的立方根

math - float 学有问题吗?

algorithm - 查询数组中数字的范围

python - 时间序列数据预处理 - numpy strides trick to save memory

Python。基于单个或多个属性构建连接对象的列表

python - 折叠笛卡尔积的结果

python - 如何首先按键按字母顺序对字典进行排序,然后按值升序排序?