- 1: Digital systems in the computer
- 2: The conversion between the digital system
- 3: Non -sign, there are symbols
- Four: Binary original code, inverse code, supplementary code, code transfer (increase code)
- 5: The reason for the introduction of the original code, anti -code, and supplement code
1. Definition of the original code
2, the characteristics of the original code
(1) The value part of the original code is the absolute value of the number, and the highest bit represents the symbol position.The highest bit is 0 is the positive number, and the highest bit is 1 is negative number。
(2) Indicates range: [-127,+127]
(3) 0 There are two representations: [+0] = 0 000 0000 ， [-0] = 1 000 0000
3, the rules of the original code
For example: number6In the computer in the computer, it is expressed as:0 000 0110Among them, the first number0is a symbol,0indicate a positive number,0000110is the number The binary data of6represents. number -6In the computer in the computer, it is expressed as:1 000 0110above is in The original code in the8bit computer indicates that if it is32bit or The16bit computer, the same method is the same, but there are a few more numbers Only0. For example: exist32bit computer number The original code of6indicates:0 000 0000 0000 0000 0000 0000 0000 011016digital in computer The original code of6indicates:0 000 0000 0000 0110
4, the operation of the original code
Rodcode represents the rules: if it is positive, then the method is the same as the original code;If it is negative, the symbol is unchanged, and the rest are counterproductive, get the back code representation of this number.
For example, numbers68Bit the inverted code in the computer is its original code:0 000 0110Number-68Bit the inverse code in the computer:1 111 1001
1. The concept of supplement code
2, the characteristics of the supplement code
(1) The only value in the supplement [0 000 0000]
(2) The negative range of the represented code can reach 2n ，[-128，+127]
（3）No symbols without symbols (used to the highest bit of the supplementary code as the symbol position)
3, supplement for the calculation
All subtraction can be converted to addition, that is, adding a negative number
4, make up for the rules of the code
supplement is a general way for computers to represent data. The rules are:
If it is a positive number, the method is the same as the original code; if it is a negative number, add the number of numbers to 1 (equivalent to reaction to the original code bit and then add 1 at the lowest position).
For example: number68The supplementary code in the computer is its original code:0 000 0110Number-68Pitch in the computer is:1 111 1010
First of all, we all know that we use decimal numbers in daily life, but use binary in the computer. If you want a computer to calculate the results such as 2 + 3, you must find a way to use binary to represent 2 and 3. But this very simple thing is to do twists and turns.
Scheme 1: Direct statement
For example: directly convert the decimal number into binary numbers.
But if you think about it, you will find that there is a problem.
How to represent the
negative number, because there are only 0 and 1 in the computer, and the positive number can only be represented by 0 and 1.
Scheme 2:Original code representation
Use 0 representative + number, 1 representative -number
Next verify whether this method is feasible:
Obviously verified, this method is not possible.
So how does the computer represent decimal number? Let’s take a look at the next plan
Scheme 3:supplement code
So the solution is feasible,Most of the computers are used to represent the number to represent the number。
And, in the form of supplementary code,All subtraction can be converted to addition, that is, add a negative form. Then when designing the CPU hardware circuit, you only need to design the adder circuit. In fact,
TheComputer does only have a magic weapon, and there is no reduction.
Extension: The data range of a byte can be represented?
Obviously the scope of 8-bit supplement: [-128,+127]