TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

NaN does not mean "I am not a number”

21 点作者 thinker将近 11 年前

5 条评论

PhasmaFelis将近 11 年前
I love the folks getting all snarky and superior at the guy who was foolish enough to suggest that &quot;Not a Number&quot; should not be a number.<p>There&#x27;s probably some cutting insight into programmer culture here somewhere.
评论 #8018157 未加载
xupybd将近 11 年前
This may be correct, but why name it NaN if its a number. I thought we were meant to write readable code. Poor naming like this in the specs really does not help.
评论 #8017812 未加载
fpaboim将近 11 年前
This discussion is ridiculous. NaN should obviously return true of isNumber, and probably just indicates you did something funky with your numbers and they exploded. They&#x27;re still numbers, you&#x27;re the one who&#x27;s at fault (I never really saw NaN come by on purpose...). It&#x27;s just that computers can&#x27;t really represent some numbers and when that happens you get NaN and as much as you want languages to read as english or be perfect abstractions sometimes practical implementations details end up surfacing and theres nothing you can do.
评论 #8019613 未加载
评论 #8019193 未加载
评论 #8019057 未加载
personjerry将近 11 年前
tl;dr: Guy suggests isNumber(NaN) should be false. But it&#x27;s true because NaN is part of floating points as defined by IEEE.<p>My own interpretation? While programmers shouldn&#x27;t care so much about this particular kind of semantics (instead they should understand the theory behind floats and never have to run into this issue) it might be better just to call NaNs something else, like &quot;undefined number&quot; or something.
评论 #8018369 未加载
评论 #8019200 未加载
derefr将近 11 年前
Isn&#x27;t this what type systems are supposed to be for?<p><pre><code> 1.0 &#x2F; 1.0 =&gt; Just 1.0 0.0 &#x2F; 0.0 =&gt; Nothing</code></pre>