News for hackers. Stuff that matters.
Re:The Secret Life of NaN by WalterBright on Monday April 27, 2026 @09:38PM (#47929550)
To leave a variable uninitialized, use the construction:

    int x = void;
Note that nobody is going to write this by accident. And it's easy to grep for.

To find the source of a NaN, it helps to know that every operation that has a NaN as an operand produces a NaN as a result. So if you see a NaN in the output, you can work backwards to where it originated.

Re:The Secret Life of NaN by jcranmer on Monday April 27, 2026 @10:47PM (#47929972)
> every operation that has a NaN as an operand produces a NaN as a result.

That's not true. The minimum/maximum functions (fmin and fminimum_num variants, but not the fminimum one) treat NaN inputs as not-present, so return the non-NaN value if there is one. Similarly, hypot also treats NaN inputs as not-present. pow and compoundn will ignore NaN exponents if the base is 1.

Re:The Secret Life of NaN by WalterBright on Monday April 27, 2026 @11:07PM (#47930066)
Yes, there are some functions where if one operand has no effect on the result, a NaN value will also have no effect.
Re:The Secret Life of NaN by ncurses1010 on Tuesday April 28, 2026 @02:31AM (#47931061)
What do you think of kotlins approach where it has a 'todo' function that can always coerce to a type, but instead of populating the variable with a default value that's valid, it just throws
Re:The Secret Life of NaN by WalterBright on Tuesday April 28, 2026 @12:43PM (#47936934)
Sorry, I know nothing about Kotlin.