Computer says - the original code, anti-code and complement

Machine number

1-- a binary number in the computer representation, the number of machines called the number. Machine number is signed, in a computer with a number of sign bits to store the most positive number of 0, a negative number. For example, the decimal number +3, the computer word length is 8 bits, is converted into binary 0000 0011, if -3 is 10,000,011. Well, here's 00,000,011 and 10,000,011 is the number of machines

True value

1 - Since there is a sign bit, the number of machines in the form of a value not equal to the true value. For example, the above signed number 10000011, which represents the most significant bit negative, its true value is not in the form of a value -3 131 (equal to 10,000,011 to dec 131). The real value of the number corresponding to the machine so that, for the sake of distinction, with the sign bit is referred to as the true value of the machine: the true value = 0000 0001 = 0001 + 000 + 1; true value of 1000 0001 = -0000001 = -1

Original code

1-- original code is the sign bit plus the absolute value of the true value, i.e., a symbol represented by a first, rest position represents a value, such as: [+ 1] = 00000001 original, [--1] = 10000001 original, first bit is the sign bit. since the first bit is the sign bit, so the range is 8-bit binary [11111111, 01111111], i.e. [-128, 127]

2 - the original code of the human brain is the most easily understood and calculated representation

Inverted

1 - indicates the inverted method are: anti-code itself is a positive number; inverted negative which is based on the original code, change the sign bit, each bit is inverted to rest, such as: [+ 1] = [ 00000001] original = [00000001] trans; [--1] = [10000001] original = [11111110] trans. If a visible anti-code representation is negative, the human brain can not intuitively see its value. To usually converted into the original code recalculation.

Complement

1-- complement representation are: complement itself is positive; a negative complement thereof is based on the original code, change the sign bit, the remaining bits inverted, last + 1 (i.e., anti-code. on the basis of 1), such as: [+ 1] = [00000001] original = [00000001] trans = [00000001] complement; [--1] = [10000001] original = [11111110] trans = [11111111] complement

2 - For negative two's complement representation of the human brain it is unable to see directly the numerical also generally need to convert the original code and then calculates its value

Overflow complement representation

1-- since the computer's complement digital representation, for example, 8 bit representation of type byte ranges: [--128, 127], such as: 0 = [0000 0000] (S)  -128 = [1000 0000] (S ) 127 = [01111111] (s)

2 - When a variable byte type super limit 127

(1)128 = 127 + 1 

     = [01111111] (S) + [0000 0001] (s) 

     = [1000 0000] (s) 

     = -128

(2)129 = 127 + 2 

     = [01111111] (S) + [0000 0010] (s) 

     = [1000 0001] (s) 

     = -127

3 - When type byte variable exceeds the lower limit of -128

(1)-129 = -128 - 1 

      = [1000 0000] (S) - [0000 0001] (s) 

      = [01111111] (s) 

      = 127

(2)-130 = -128 - 2 

       = [1000 0000] (S) - [0000 0010] (s) 

       = [01111110] (s) 

       = 126

4 - regard to complement overflow, can be used to describe a map (in Example 8 bit)

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/self-epoch/p/10968981.html