logoalt Hacker News

WalterBrightyesterday at 10:19 PM1 replyview on HN

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.


Replies

AlotOfReadingyesterday at 11:16 PM

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++).

show 2 replies