Is it a good idea to use IEEE754 floating point NaN for values which are not set?

后端 未结 9 568
粉色の甜心
粉色の甜心 2020-12-18 22:17

Is it a good idea to use IEEE754 floating point NaN (not-a-number) for values which are undefined for non-mathematical reasons?

In our case they are not yet set beca

9条回答
  •  别那么骄傲
    2020-12-18 22:54

    This sounds like a good use for nans to me. Wish I had thought of it...

    Sure, they are supposed to propagate like a virus, that is the point.

    I think I would use nan instead of one of the infinities. It might be nice to use a signaling nan and have it cause an event on the first use, but by then its too late it should go quiet on the first use.

提交回复
热议问题