Skip to content
DevMeme
2283 of 7590
CS Fundamentals Post #2540 · source on Telegram

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

17
Anonymous ★ Top Pick 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
  1. Anonymous ★ Top Pick

    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

  2. Anonymous

    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

  3. Anonymous

    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

  4. Anonymous

    IEEE 754's eternal gift: NaN == NaN? False - because even bits need plausible deniability in prod

  5. Anonymous

    x != x - the day IEEE‑754 teaches you equality isn’t reflexive and your dedupe job quietly hoards NaNs

  6. Anonymous

    Math: x! = x -> {1,2}. JavaScript: x!=x -> NaN. Classic postmortem: notation leaked across bounded contexts

  7. @ImJmik 5y

    Never Oh, stop......

  8. @tarasssssssssssssss 5y

    JS jokes or what idk

  9. Deleted Account 5y

    i dont get the maths bit

    1. @bit69tream 5y

      x! is factorial of x

      1. Deleted Account 5y

        oh

      2. @metal_Dash 5y

        Гений

  10. @TTpocT 5y

    А, я думал не равен

  11. @null_po 5y

    If you say a number loudly, then its value will increase: 5 = 5 5! = 120

    1. @freeapp2014 5y

      But if you say it even more loudly, it will go back down 5!! = 15

      1. @x_Arthur_x 5y

        How is that so?

        1. @freeapp2014 5y

          https://en.m.wikipedia.org/wiki/Double_factorial

Use J and K for navigation