help-octave
[Top][All Lists]
Advanced

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

Re: NA & operations with it


From: Mike Miller
Subject: Re: NA & operations with it
Date: Thu, 21 Nov 2013 09:21:43 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10

On Thu, 21 Nov 2013 14:08:15 +0100, Daniel Kraft wrote:
> Hi!
> 
> I just chased a bug in my Octave codes, and found that it was related to
> my usage of NA to denote special cases for entries of some data
> structures.  In particular, I found that -NA = NaN and not NA again.
> 
> So far, so good.  However, I experimented a bit further, and found that
> "almost all" other (linear) operations with NA in fact return NA again:
> 
> +NA, 0 - NA, 1 * NA, Inf + NA, NaN * NA, and others
> 
> So why is just -NA not NA but NaN instead?  Is this a deliberate choice,
> or just an edge case no-one has thought about so far?  I take it that
> one should probably not rely on any of those (and I changed my code now
> accordingly), but it still seems curious to me; and if there was no
> actual reason for this behaviour, I would suggest to change it to make
> it consistent.  (I can try to provide a patch.)

This looks like an oversight to me. It seems to me that -NA should have
the same result as 0 - NA and -1 * NA, both equal to NA.

>From a quick glance I think it's because NA is a specific NaN constant
in liboctave, and -NA changes the sign bit so it is no longer the same
specific value.

Best to report a bug so this isn't forgotten, even if you are intending
to work on it.

-- 
mike


reply via email to

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