[Kstars-devel] Handling the "data unavailable" cases with NaNs.

Aleksey Khudyakov alexey.skladnoy at gmail.com
Mon Mar 18 08:50:02 UTC 2013


>> All in all it seems reasonable to me but floating points are tricky
>> so care is needed
>
> In what sense? You mean, for example, comparisons involving NaN almost
> always yield "false" and the law of trichotomy doesn't hold for NaNs
> :D?
>
Yes. Because of it it's easy to write code which handles NaN
incorrectly. For example:

> if( x < 0 ) then { invalid input case } else { valid input }

Here NaN will propagate into branch which assume that input is valid.
It's also easy to
forget that some value may actually be NaN. Most of the time double
are not NaN or infinities.
So it absolutely must be documented.


More information about the Kstars-devel mailing list