Binary code and complement the original conversion

1. conceptual understanding (note that the anti-complement code and the original code is positive, negative is the inverted complement plus 1)
positive: the original code symbol = = trans complement
positive example (number 3): 11 (formerly code) = 11 (inverted) = 11 (complement)
negative: invert the original code = inverted; 1 = + inverted complement
negative example (the number -3): 111 (original code) -> 100 (anti-code ) -> 101 (complement) (Note that the first sign bit is 1, n is 0, 1 negative)

2. The code conversion and complement
to Example -3:
original code -> complement: 111 (formerly code) = 100 (inverted) = 101 (complement)

Complement -> original code: 101 (complement) -> 110-> 111 (original code)


Law: original code -> conversion rule also applies to the complement of the complement -> original code, but also add a negated
Law Analysis: In Case 5, the original code and the inverted variables a and b respectively in place
provided: original code = a = 101; the inverted = b = 010; + trans original code symbol = 111 = sum;
according to the original code - rule> complement, by a push on a:
a + B = SUM;
complement the original code = sum- + 1 = sum-a + 1 ;
the complement -> the original code rule, by a push on a:
complement = sum-a + 1;

Invert +1: sum- (sum-a + 1) + 1 = a-1 + 1 = a = original code

Summary: The original code -> conversion rules apply equally to complement complement -> original code, but also negated plus 1

Guess you like

Origin blog.csdn.net/ly853602/article/details/80575694