Commutative property of arithmetic operations with NA and NaN

Erik Leunissen <[email protected]>
Newsgroups gmane.comp.gnu.octave.general
Message-ID <[email protected]>
Are the rules of commutativity for binary arithmetic operators also valid (or make sense) for the 
exceptional values NaN and NA?

I'm observing the following results with multiplication, division, addition and subtraction (didn't 
bother to try other operations):

octave:1> NaN*NA
ans = NA
octave:2> NA*NaN
ans = NaN

octave:3> NaN/NA
ans = NaN
octave:4> NA/NaN
ans = NA

octave:5> NaN + NA
ans = NA
octave:6> NA + NaN
ans = NaN

octave:7> NaN - NA
ans = NaN
octave:8> NA - NaN
ans = NA

Please note that the above results originate from "playing with exceptional values"; I have no 
use-case. Moreover, I'm unfamiliar with theory regarding NaN and NA.

Nevertheless, I dare say that the different results for multiplication (octave commands 1 and 2 
above) and the different results for addition (octave commands 5 and 6) don't make any sense to me.

As for the results for division and subtraction, my "judgement" about validity of these results is 
less pronounced. But considering only that NaN and NA have a profoundly different meaning (to me 
they seem to exist on entirely different dimensions/scales), I can imagine that swapping the 
operands ought not make a difference for the result.

I'd be very interested in a more knowledgeable judgement.

TIA,
Erik Leunissen.
--
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.