What uses do floating point NaN payloads have?

It was thought to be a good idea when IEEE754 and NaN’s were developed. I have actually seen it used to store the reason why a NaN was created.

Today, I wouldn’t use it in portable code for several reasons. How sure are you that this payload will survive for example an assignment? If you assign x = y, how sure are you that x has the same NaN payload as y? And how sure are you that it will survive arithmetic? If a or b is an NaN, then a op b is supposed to be the one NaN, or one of the two NaNs if they are both NaN. Sure that this is the case? I wouldn’t be willing to bet on it.

Leave a Comment