gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: altitude validity


From: Gary E. Miller
Subject: Re: altitude validity
Date: Tue, 4 Feb 2020 17:40:03 -0800

Yo Greg!

On Tue, 04 Feb 2020 19:23:58 -0500
Greg Troxel <address@hidden> wrote:

> "Gary E. Miller" <address@hidden> writes:
> 
> >> So this notion of NaN makes a lot of sense, but it was unobvious
> >> from reading gps.h and from reading the libgps man page.  
> >
> > No one gets NaN the first few times.  Libraries constantly get it
> > wrong. I have seen sevaral bug reports on major languages in the
> > last week about NaN misunderstanding.  
> 
> It's not that I don't understand NaN.  It's that there is a field,
> with comments about when it's valid.

Comments are not code.

> So if it's supposed to be
> valid, it has to contain a number that is right-ish.  And if it's not
> supposed to be valid, one shouldn't even look at it.

Having a valid bit for every field doubles the work required.  Much
easier to have one test instead of two.  Plus it catches math errors
for free.

Going to NaNs fixed a number of errors and saved a ton of code.

Whenever you have two variables that say the same thing, they will get
out of sync.  Always better to use just one if possible.

> The notion that the field is either NaN or valid is a reasonable one,

Good.

> but it is not the default assumption for an interface.

This is code, never assume.

> If the comment
> said "This is either NaN, signifying that the field is not valid, or
> else contains a valid value." that would be fine.

If you want to submit that patch for the hundreds of variables, have at it.

Otherwise, that is default IEEE floating point convention.

> But it does not
> make senes to expect people to guess that, especially when the
> comments hint hotherwise.

Which comments "hint" otherwise?  I'll fix those.

> >> I am also unclear on that ALTITUDE_SET means, if one is supposed to
> >> check against NaN.  
> >
> > It means nothing.  Note that is it undocumented.  Ignore it.  I
> > would remove it, but there is so much legacy code that all I can do
> > is deprecate it.  
> 
> That really calls out for a comment in the header.    People should be
> able to read the .h (or something) and understand the interface.

Suggestions welcome.  But it seems to me anyone doing floating point
that fails to frequently check for NaNs has no business in the code.
That should have been in everyones CS 101.

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        address@hidden  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Attachment: pgp_4M3Nun9Ir.pgp
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]