Realizing x != x for NaN triggers the cat-stare during code review
Description
The meme is split into a text header and a two-panel photo. Header text reads: "Teacher: When is x!=x ?\nMe: When x equals to 1 or 2.\nTeacher: Then why you did you write NaN on the paper?\nMe:". In the left photo a person (face blurred) sits at a dining table holding printed papers while a grey Scottish-fold cat sits beside them, staring at the sheet. A closed space-grey MacBook rests on a red placemat in the foreground. The right photo zooms in on the cat’s wide-eyed, mildly panicked expression as it confronts the paper. The joke relies on IEEE-754 floating-point semantics where the special value NaN is the only value for which the comparison x != x evaluates to true, often surprising students and developers. It humorously captures the classic floating-point edge case and the confusion it causes during teaching or code reviews
Comments
17Comment deleted
When I hit `if (x != x)` in the hottest loop: sure, it’s the IEEE-754-certified NaN check, but now both the branch predictor and every reviewer look exactly like that cat
After 20 years in the industry, I've learned that explaining IEEE 754 floating-point edge cases to non-programmers is harder than explaining to the board why our microservices need another orchestration layer - at least the board pretends to understand
The beauty of NaN is that it's the only value in programming that's so special, it refuses to be equal to itself - a perfect metaphor for that one microservice in your architecture that never agrees with its own health checks. IEEE 754 basically said 'undefined behavior deserves undefined equality,' and now we all get to explain to junior devs why `NaN === NaN` returns false while they question their entire understanding of mathematics and reality itself
IEEE 754's eternal gift: NaN == NaN? False - because even bits need plausible deniability in prod
x != x - the day IEEE‑754 teaches you equality isn’t reflexive and your dedupe job quietly hoards NaNs
Math: x! = x -> {1,2}. JavaScript: x!=x -> NaN. Classic postmortem: notation leaked across bounded contexts
Never Oh, stop...... Comment deleted
JS jokes or what idk Comment deleted
i dont get the maths bit Comment deleted
x! is factorial of x Comment deleted
oh Comment deleted
Гений Comment deleted
А, я думал не равен Comment deleted
If you say a number loudly, then its value will increase: 5 = 5 5! = 120 Comment deleted
But if you say it even more loudly, it will go back down 5!! = 15 Comment deleted
How is that so? Comment deleted
https://en.m.wikipedia.org/wiki/Double_factorial Comment deleted