TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

NaN does not mean "I am not a number”

21 pointsby thinkeralmost 11 years ago

5 comments

PhasmaFelisalmost 11 years ago
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 未加载
xupybdalmost 11 years ago
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 未加载
fpaboimalmost 11 years ago
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 未加载
personjerryalmost 11 years ago
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 未加载
derefralmost 11 years ago
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>