Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>but apparently this is useful for some reason.

It lets you easily test whether a value is NaN without needing a library function call. (Even if the language wanted to provide a NaN literal, there's more than one NaN value, so that wouldn't actually work!)



This test is better with a function call, because it clearly shows the intent. Perf-wise, this function call will be inlined by any decent compiler. https://godbolt.org/z/chhM85vP3

Breaking a basic programming expectation for a specific class of values of a specific type is not a good thing, in my opinion.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: