[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Commutative property of arithmetic operations with NA and NaN

**From**: |
Erik Leunissen |

**Subject**: |
Commutative property of arithmetic operations with NA and NaN |

**Date**: |
Wed, 30 Dec 2020 22:04:09 +0100 |

**User-agent**: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 |

`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.
--

**Commutative property of arithmetic operations with NA and NaN**,
*Erik Leunissen* **<=**