# How NaN Breaks Python and Lua Language Design Assumptions

Original title: Two Case Studies of NaN

> Hacker News story 48855045 · language: en · submitted 2026-07-10
> Web version: https://zeli.app/story/48855045
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 4 · by [ryantsuji](<https://news.ycombinator.com/user?id=ryantsuji>) · 💬 0
[original](<https://sebsite.pw/w/20260709-nan.html>) · [HN discussion](<https://news.ycombinator.com/item?id=48855045>)

## Summary

I discovered two surprising cases where IEEE-754 NaN values break implicit assumptions in programming language design. In Python, list equality checks fail because NaN does not equal itself, violating reflexive rules. In Lua, numerical for-loops behave unpredictably when NaN is used as a limit or step, leaking internal comparison logic. These oversights show how weird NaN behavior can silently corrupt language semantics.

## Key quote

> NaN is weird, and that means other things behave weirdly with it.

## HN discussion (0 comments)

### [fragmede](<https://news.ycombinator.com/item?id=48904242>)

> Wat.
>
> I wish there were a recent remake of it.

### [ColinWright](<https://news.ycombinator.com/item?id=48904414>)

> See also: https://news.ycombinator.com/item?id=48903701

### [whatever1](<https://news.ycombinator.com/item?id=48903461>)

> Just store what you mean to store for gods sake. We have been fighting with over-designed bs for decades.
>
> Zero is not absence of a value. It has a value, it happens to be 0. Same for undefined/infinity. They exist.
>
> Let the hardware engineers figure out an efficient way to deal with it. If it costs more, well if we add up all of the costs of bugs due to zero/null conversions, maybe it was worth it.

---

## Cite

- Page: https://zeli.app/story/48855045
- Date: 2026-07-10
- Source: sebsite.pw (https://sebsite.pw/w/20260709-nan.html)
- Hacker News: https://news.ycombinator.com/item?id=48855045

## Other languages

- zh: https://zeli.app/zh/story/48855045 · markdown: https://zeli.app/zh/story/48855045.md
- ja: https://zeli.app/ja/story/48855045 · markdown: https://zeli.app/ja/story/48855045.md
- ko: https://zeli.app/ko/story/48855045 · markdown: https://zeli.app/ko/story/48855045.md
- de: https://zeli.app/de/story/48855045 · markdown: https://zeli.app/de/story/48855045.md
- es: https://zeli.app/es/story/48855045 · markdown: https://zeli.app/es/story/48855045.md
