Two Case Studies of NaN
2 days ago
- #Programming language design
- #Floating-point behavior
- #NaN quirks
- Python's list equality optimization compares elements by identity first, which assumes an object always compares equal to itself, an assumption violated by NaN.
- In Lua's numerical for-loops, NaN leads to unintuitive behavior because the implementation's comparison logic breaks when checking limits and steps with NaN, which is likely an oversight.
- NaN's unique properties often cause programming language design choices or optimizations to fail, as seen in Python, Lua, and previously documented cases like Go map keys.