NaN为什么不是有限的? [英] Why isn't NaN finite?

查看:78
本文介绍了NaN为什么不是有限的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

测试isFinite函数,我发现NaN是一个无限数字(即使它不是一个数字 :-)).

Testing the isFinite function I see that NaN is an infinite number (even if it's not a number :-)).

isFinite(NaN) // returns false

这背后的逻辑是什么?为什么NaN不是有限的?

What's the logic behind this? Why isn't NaN finite?

推荐答案

正如戴夫·牛顿(Dave Newton)所说,NaN不是数字,因此您必须考虑它不是有限的也不是无限的. 这些事情也会发生同样的事情:

As Dave Newton said, NaN is not a number, and then you have to consider that it isn't finite nor infinite. The same occurs to these:

NaN > 0  // false
NaN < 0  // false

您可能想阅读以下文章:

You might want to read these articles:

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite

这篇关于NaN为什么不是有限的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆