On Sat, 18 Jul 2020 08:20:09 -0700, Charles Mills wrote:

>Or, more formally, addition is commutative but subtraction is not.
>
>A + B always* equals B + A, but A - B generally does not equal B - A.
>
>*Is that true for computer languages (as opposed to being true only for pure 
>math)? In modern C++ if I say
>
>auto x = y + z;
>
>If y and z are of different types (float and integer; 64-bit and 32-bit) does 
>x take the type of the first operand, and thus y + z yields a different result 
>than z + y?
>
I think it's mostly dominant type.  But there may have been a transition
from unsigned-preserving to value-preserving.  So it may no longer be true
that -1 > (unsigned)0.

Since C defines subscripting in terms of addition and addition is commutative,
"wombat"[3] may be written as 3["wombat"]; both evaluate to 'b'.

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to