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

Aleksey Khudyakov alexey.skladnoy at gmail.com
Sun Mar 17 09:35:30 UTC 2013


On 17.03.2013 01:00, Akarsh Simha wrote:
> Hi
>
> I have a suggestion. Many a times, data like magnitudes could be
> undefined. Right now, we just supply some numbers for unavailable data
> (eg: 99.99 for the magnitude, and I think exact zeros for RA and Dec).
>
> I think it might be better to replace these by NaNs, so errors in
> these objects will not propagate. Of course, we should add code
> everywhere to handle these NaNs properly.
>
> This is a drastic change because it could result in segfaults
> everywhere. So I thought I should discuss it before I do something
> like this.
>
Defining characteristic of NaNs is that they are contagious. Every 
computation with NaN will produce NaN. So one way to handle NaNs is to 
perform calculations as if they are normal numbers and then check 
whether result is NaN. It's reasonable if there isn't many NaNs and if 
it reduces number of checks

To my knowledge NaNs and floating point numbers in general cannot cause 
SIGSEGV. But if handling of floating points is enabled (I've checked and 
it seems to be off by default) you'll get SIGFPE signal.

All in all it seems reasonable to me but floating points are tricky so 
care is needed


More information about the Kstars-devel mailing list