News for hackers. Stuff that matters.
Re:One does not simply calculate the absolute value by Dylan16807 on Monday August 23, 2021 @03:13AM (#28273059)
> I don't see anything else using a pointer to code in production.

If you log it, you could trace it back to the line of code at your leisure.

> It would also lead to problems like: x = 5.0 * y y is NaN with some address as the NaN type. NaN * 5.0 => NaN. Which address (the original or the * 5.0 line) is used?

I don't mean to be rude, but isn't the answer to that question extremely obvious?

The behavior that's much more useful and enshrined in the IEEE spec is that you keep the original NaN.

Re:One does not simply calculate the absolute value by HWR_14 on Monday August 23, 2021 @11:25AM (#28277274)
If you log it, why wouldn't you just log it at creation time. Are you going to periodically scan all floating-point numbers used everywhere in your code to see where they are created?

> The behavior that's much more useful and enshrined in the IEEE spec is that you keep the original NaN.

I didn't realize it was in the spec. I just checked, and you're right! That does however seem strange - X was never set by operation NNNN, Y was.

Re:One does not simply calculate the absolute value by Dylan16807 on Monday August 23, 2021 @03:54PM (#28281094)
To me, trying to handle exceptions every time a NaN shows up sounds like it's riskier to performance than a few checks at important places. You wouldn't scan. Probably depends on code base.

> That does however seem strange - X was never set by operation NNNN, Y was.

If you're using NaN payloads, it would almost never be helpful for 95% of your NaNs to turn into a generic "used a NaN in arithmetic" version.