this post was submitted on 14 Nov 2026
394 points (97.4% liked)

Programmer Humor

34181 readers
867 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 3 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] b3nsn0w@lemmy.world 49 points 2 days ago (3 children)

duh, it's part of the IEEE 754 standard. every language that handles floating point numbers has NaN handling, and in every language NaN is a float. the only reason this is brought up as a javascript thing all the time is that js doesn't have separate float and int types (aside from special structures like typed arrays and dataviews), it just defaults to float64 for simplicity and calls it number, which lines up with the "NaN is a number? nani???" joke.

you don't like it? consult the sorry excuse of thinking sand in the device you're reading this on, because this is etched straight into it. every FPU capable of handling float32 and float64 numbers knows what NaN is and handles it the exact same way.

this is one of the many things that sound unintuitive about programming but if you bother to understand the context you realise that if it wasn't this way, it would be way worse. one of the most important skills in our field is to understand computers for what they are, rather than be puzzled that they aren't what you thought they were, and it especially comes out in edge cases like this.

[–] aksdb@lemmy.world 20 points 1 day ago* (last edited 1 day ago) (1 children)

To add to this: the state of being not a number is only relevant to a number. Everything that’s already not a number doesn’t need a specific value to represent this state. It’s actually quite logical.

Apparently one of the few examples of JS not being weird.

[–] Heavybell@lemmy.world 1 points 1 day ago

It is easier to understand the non-weirdness of it in a strongly typed language, IMO. But yes.

[–] alsimoneau@lemmy.ca 2 points 1 day ago (1 children)
[–] arty@feddit.org 11 points 1 day ago (1 children)
$ python 
Python 3.14.4 (main, Aug 20 2026, 10:41:58) [GCC 15.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> type(float('nan'))
<class 'float'>
[–] alsimoneau@lemmy.ca 1 points 8 hours ago (1 children)

That never arises in normal use though. I didn't even know it existed since anything that would yield one raises an exception instead.

[–] arty@feddit.org 1 points 6 hours ago

But the OP complains specifically about typeof NaN, and not about Math.sqrt(-1) // NaN

I know this doesn’t count as "normal use", but in Python you get it e.g. via math.inf * 0.

Excellent, now do nulls!

[–] ChickenLadyLovesLife@lemmy.world 9 points 1 day ago (1 children)

Stop calling it "NaN bread" -- NaN is fucking bread!

[–] StuffYouFear@lemmy.world 6 points 1 day ago (1 children)

I want naan bread with my chai tea

[–] some_kind_of_guy@lemmy.world 4 points 1 day ago

I'll split the check with you! Just gotta run to the ATM machine and I'll get $20 dollars (as long as I can remember my PIN number)

[–] Jankatarch@lemmy.world 48 points 2 days ago* (last edited 2 days ago)

> "Not a Number"
> Look inside.
> number

[–] ThunderComplex@lemmy.today 77 points 2 days ago (19 children)

I think this, and the fact that NaN == NaN is false, make perfect sense.
NaN is the result of mathematically undefined behavior. You’re not going to get a NaN outside of a number context, so tying it together in the Number scope is fine.

[–] LillyPip@lemmy.ca 4 points 2 days ago (1 children)

Same reason NULL != NULL. It makes sense if you understand how these values work.

[–] SpaceNoodle@lemmy.world 18 points 2 days ago (2 children)
[–] LillyPip@lemmy.ca 9 points 2 days ago* (last edited 2 days ago) (1 children)

https://richiban.uk/2016/12/21/does-null-equal-null/

ISNULL may be true, whilst NULL != NULL. NULL is not a value.

[–] SpaceNoodle@lemmy.world 18 points 2 days ago (1 children)

Ah, my brain was in C mode, where NULL is functionally 0. This is about the concept, which doesn't apply equally to all languages.

[–] LillyPip@lemmy.ca 9 points 2 days ago* (last edited 2 days ago)

Yep. There are some languages where this applies, because it’s a mathematical concept. The point is it’s the same ‘no value’ concept, which isn’t ~~shared by~~ implemented the same way by all languages.

C is strongly typed, and uses pointers, so NULL sort of intrinsically has a value in C.

edit: my wording was a bit off

[–] djmikeale@feddit.dk 5 points 2 days ago* (last edited 2 days ago)

You can kinda think of it as null meaning undefined. In this case, "undefined does not equal undefined" seems easier for me to wrap my head around

load more comments (18 replies)
[–] bss03@infosec.pub 51 points 2 days ago (2 children)
[–] lena@gregtech.eu 17 points 2 days ago

I love that talk.

And yes, this post is low-effort, but so are most posts on here. Just a bunch of screenshots from various microblogging platforms reposted from Reddit.

[–] Aedis@lemmy.world 5 points 2 days ago

Came in here to make sure this is posted.

[–] Kolanaki@pawb.social 1 points 1 day ago

I've never had number naan before... Is it any good? 🤔

[–] dylanTheDeveloper@lemmy.world 11 points 2 days ago (1 children)

Technically everything is a number when you get low enough

[–] Lemminary@lemmy.world 5 points 1 day ago

Bro I'm too high for this

[–] Quetzalcutlass@lemmy.world 41 points 2 days ago* (last edited 2 days ago)

It's of type Numbn't.

[–] General_Effort@lemmy.world 4 points 1 day ago

It is the number that must not be; that cannot be. These 3 letters are all that stand between you and the ultimate cosmic horror.

It is not for nothing that the sender of eight is also known as the soul-render. Which is why a sensible wizard will never mention the number if they can avoid it. "Or you'll be eight alive."

[–] GreenKnight23@lemmy.world 2 points 1 day ago

yup. that's JavaScript.

[–] thethunderwolf@lemmy.dbzer0.com 10 points 2 days ago

this makes sense

NaN is a "this was meant to be a number but it somehow isnt"

[–] baramintal@lemmy.org 3 points 1 day ago

The beauty of JavaScript.

You probably haven't encountered truthsy and falsy values yet?

[–] TrickDacy@lemmy.world 12 points 2 days ago (2 children)

JavaScript really isn't as bad as people want it to be

load more comments (2 replies)
[–] Colloidal@programming.dev 15 points 2 days ago

It's clearly bread.

[–] palordrolap@fedia.io 18 points 2 days ago (2 children)

Infinity is also a number in JavaScript / IEEE number formats, but you'll get a lot of grumbling from mathematicians with that sort of assertion.

[–] anton@lemmy.blahaj.zone 4 points 1 day ago (1 children)

Once you accept that each float represent a range of reals most design decisions make sense.
Infinity is just the name given to values that are too large to represent otherwise and negative zero includes negative values too close to zero.

What mathematics probably hate most about floats is that rounding breaks commutativity.

[–] bss03@infosec.pub 2 points 1 day ago (1 children)

What mathematics probably hate most about floats is that rounding breaks commutativity.

Actually, the maths people in my circles tend to complain more about how the normal floating-point equality test doesn't define an equivalence relation, but really any of the violations of field properties can attract complaints.

[–] anton@lemmy.blahaj.zone 2 points 1 day ago* (last edited 1 day ago)

When writing my comment I had successfully repressed that fact in my mind. That's obviously worse.

load more comments (1 replies)
[–] bigmclargehuge@lemmy.zip 15 points 2 days ago

The way I think about it: number is a js type. A floating point double, in other languages.

NaN is a state that a number type can be in, representing a situation where the outcome of the numeric operation cannot be determined.

Anywho, also yea ….JavaScript is goofy

[–] Everyday0764@lemmy.zip 1 points 1 day ago

there is a game / challenge for this

load more comments
view more: next ›