javascript - 为什么 Math.pow(1, NaN) 在 JavaScript 中等于 NaN?

标签 javascript

IEEE 754-2008"9.2.1 Special values"有提到

pow(+1, y) is 1 for any y (even a quiet NaN)

如果没有阅读整个文档,维基百科给出了 shortcut :

The 2008 version of the IEEE 754 standard says that pow(1, qNaN) and pow(qNaN, 0) should both return 1 since they return 1 whatever else is used instead of quiet NaN.

为什么 Math.pow(1, NaN) 在 JavaScript 中是 NaN?不符合标准吗?

最佳答案

是因为the ECMAscript specification好像是这么说的。

pow (x, y)

Returns an implementation-dependent approximation to the result of raising x to the power y.

  • If y is NaN, the result is NaN.
  • ... other constraints...

关于javascript - 为什么 Math.pow(1, NaN) 在 JavaScript 中等于 NaN?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14937880/

相关文章:

javascript - 语音合成 API 在说话时突出显示单词

javascript - svg.js - 如何从 SVG 文本元素获取 X 位置

javascript - 改变状态后保存健康、乐趣、金币

javascript - 在剧作家测试中切换标签

javascript - jquery show hide div 但 onchange 记住它

javascript - 使用 json 对象中变量的参数名称

javascript - 如何从最接近的 'tr' 的第 n 个元素获取值?

javascript - 计算出执行 AJAX 请求需要多少时间

javascript - vuejs动态添加占位符

javascript - 将名称与组映射的有效解决方案