私はそれが結合的で可換であることを知っています:
あれは、
(~x1 + ~x2) + ~x3 = ~x1 + (~x2 + ~x3)
と
~x1 + ~x2 = ~x2 + ~x1
ただし、私が試したケースでは、分配的ではないようです。つまり、
~x1 + ~x2 != ~(x1 + x2)
これは本当ですか?証拠はありますか?
次のようなCコードがあります。
int n1 = 5;
int n2 = 3;
result = ~n1 + ~n2 == ~(n1 + n2);
int calc = ~n1;
int calc0 = ~n2;
int calc1 = ~n1 + ~n2;
int calc2 = ~(n1 + n2);
printf("(Part B: n1 is %d, n2 is %d\n", n1, n2);
printf("Part B: (calc is: %d and calc0 is: %d\n", calc, calc0);
printf("Part B: (calc1 is: %d and calc2 is: %d\n", calc1, calc2);
printf("Part B: (~%d + ~%d) == ~(%d + %d) evaluates to %d\n", n1, n2, n1, n2, result);
次の出力が得られます。
Part B: (n1 is 5, n2 is 3
Part B: (calc is: -6 and calc0 is: -4
Part B: (calc1 is: -10 and calc2 is: -9
Part B: (~5 + ~3) == ~(5 + 3) evaluates to 0