Remix.run Logo
WalterBright 4 hours ago

Another crucial use of NaNs is if you have a sensor. If the sensor has failed, the sensed value should be transmitted as NaN, not 0, so the receiver knows the data is bad.

AlotOfReading 3 hours ago | parent [-]

My experience is that if you write an interface that (rarely) returns NaNs, someone will use it assuming it's never NaN no matter how good the docs are. Then their code does bad things and you have to patiently explain why they're wrong and yes, they are holding isnan() wrong (in C/C++).

WalterBright an hour ago | parent [-]

NaN for a failed sensor is objectively better than any other value. But at some point you just cannot help some people.