-
In computer systems, numerical values are always represented and stored in complement codes.
In computers, there are no original and reverse codes. Therefore, the conversion of the original code and the reverse code, and the complement code, is meaningless.
All you need to do is master the "conversion of values and complements", and that's enough.
In the following table, there is the relation for this transformation:
-
In the computer, there is no original code and reverse code, only complement code.
The complement code is naturally formed in the computer and has nothing to do with the original code or the reverse code.
For the complement, it should be discussed directly in binary, and do not detour to the non-existent original code to go up.
The octabit is illustrated below.
The number 0 is stored with eight digits: 0000 0000.
The number 1 is the binary of zeros, subtracting one, i.e.
0000 0000 1 1) 1111 1111, there are still eight digits, which is 1111 1111 (decimal 255).
With the number 2, you subtract one more and that's 1111 1110 (=254).
With the number 3, you subtract one more and that's 1111 1101 (=253).
。128 is subtracted by 128 times, and finally 1000 0000 (=128).
These are the complements of negative numbers. Formula: 256 negative numbers256 corresponds to a positive numberThe complement of 18 is:
256 18 238 = 1110 1110 (binary).
If you use "the original code inverse symbol bit is taken and added by one" to calculate, this is also the result.
When you're bored, then ** the original code is reversed, and it's useless anyway.
-
Take the 8-digit machine code as an example:
For positive numbers, the original, inverse, and complement codes are all the same.
The decimal number 7 is: 00000111
For the 7 original code, only the highest bit is represented by a negative number with 1, which is:
The reverse code is on the original code, except for the highest bit (sign bit), according to the bit of the negation:
Complement code is on the basis of the reverse code, the lowest bit plus 1:
-
Signed numbers, which can be changed into various **, see Fig.:
However, both the original code and the reverse code do not exist in the computer.
Only the complement code is a practical code.
The law of its transformation can be found out by itself.
-
Complement, in fact, is a positive number that [operates instead of a negative number].
When you replace negative numbers with complements, negative numbers don't exist in your computer.
As a result, there is no subtraction in the computer.
In other words, with the help of complements, the calculations can be simplified. It also simplifies the hardware.
How can a complement (a positive number) be used to "replace a negative number"?
Let's look at the 2-digit decimal arithmetic:
28 + 99 = one hundred) 27
As long as you ignore the carry (10 2), the function of +99 and 1 is the same.
In this case, +99 is said to be the complement of 1.
In the same way, +98 is the complement of 2.
You can also derive the formula for finding complements:
Complement negative number + 10 n, n is the number of digits of complement.
ComputersWith binary, complement, renamed as: complement.
For 8-bit binary, the complement should be found as follows:
Formula: Complement Negative + 2 n, n is the number of bits of the complement.
8-bit base, which can make up a total of 2 8 = 256 sets of complements.
This includes 128 negative complements.
As follows: [1] Complement = 2 8 1 = 255 = 1111 1111 (binary).
2] complement = 2 8 2 = 254 = 1111 1110 (binary).
128] complement = 256 128 = 128 = 1000 0000.
Positive, non-transformable, must directly participate in the operation.
So, positive, there is no complement.
Neither the source code nor the reverse code has the function of simplifying the hardware.
Therefore, in the computer, only the complement code is used, and the original code and reverse code are not used at all.
To find the complement, don't take the road of "the original code is reversed and the symbol bit is added to the one".
Otherwise, you wouldn't know: Ho? For? Repair? Yard?
Calculated with eight-digit complement: 7 5 = 2.
5] complement =
Add
Carry more than 8 digits, just discard it.
From this calculation, it can also be seen that:
When you use complement and subtraction, you convert it to addition.
The original code is reversed, and there is no such function.
So, in the computer, there is no shadow of them at all.
-
Original: In the number represented by the binary original code, the sign bit 0 represents a positive number, the sign bit 1 represents a negative number, and the rest of the digits represent the numeric part. For example, 10000010 means -2,00000010 means 2.
Anti-code: The definition of anti-code is as follows:
For positive numbers, its inverse representation is the same as the original. i.e. [x] anti = [x] original.
For negative numbers, except for the sign bit which is still "1", the rest of the "1" is replaced with "0", and "0" is replaced with "1", that is, the inverse code [x] is obtained. For example, [11101001] inverse=10010110.
For 0, it has two representations of inverse codes: [+0] inverse=00....0 [-0] anti = 11....1
Complement: The complement of a positive number is the positive number itself.
01100100] Supplement 01000100
For negative numbers: the sign bit remains unchanged, and the inverse code is added by 1.
10100100] Supplement 11011011
0] complement [-0] complement 00....0。
Hope mine can help you.
-
62 The original code is 01000001, and the reverse code and complement code are the same as the original code.
62 original code 11000001:
Anti-code 10111110
Complement 10111111
For example: 64 original code reverse code complement code 0100 0000.
10 original code 1000 1010;
10 reverse code 1111 0101;
10 Supplement 1111 0110.
Add the complements to get 0011 0110, which is the complement of 54.
-
In computer systems, numerical values are represented and stored in complements. Absolutely slippery
The calculation of the complement is exactly the same as the algorithm for normal binary numbers.
In the computer, there is no original grinding code and anti-code at all.
How to calculate the original code and the reverse code? The devil knows.
-
How to convert the original code of the reverse code complement, let's take a look at the method.
1. First of all, the highest digit of the original ** is the bit of the symbol bureau, 0 means positive, 1 means negative, and the middle value represents the absolute value of the number.
2. The inversion of the symbol, the inversion of the positive sign is the same as the original symbol, and the complement of the negative number is the least significant digit of the symbol plus 1.
3. Complement, the complement of positive numbers is the same as the original **, and the complement of negative orange friends is added to 1 on the basis of its penultimate first. Zero is divided into +0 and -0. When adding different symbols or subtracting the same symbol, you cannot directly add or subtract, and you cannot directly give positive and negative results.
4. The absolute value must be taken first, and then subtraction must be added. The symbol bit is determined by a large absolute value, so there is a transcoding of Tong Wu Xun. The reverse code is an improvement on the original.
Complement solves the problem of addition and subtraction and plus and minus zeros, and the most commonly used is complement.
-
In computer systems, numerical values are always represented and stored in complements.
Complement, in fact, is a positive number that [operates instead of a negative number].
With the use of complements (positive numbers), there are no negative numbers in the computer.
And then there's no subtraction.
So, with the help of complements, the computer only needs to configure an adder to go all over the world.
The purpose of using complements is to simplify the hardware of your computer.
The original code and the reverse code do not have this function, so they are not used in the computer at all.
Therefore, neither the original code nor the reverse code exist in the computer.
How can a complement (a positive number) be used to "replace a negative number"?
You seeHour hand: 3 hours backwardsYesPositive dial 9 hoursInstead, right?
You look at trigonometric functions:2, +3 2, the value of the function is also the same.
A decimal number, if limited to only 2 digits, then there will be:
25 + 99 = one hundred) 24
If you ignore the carry of a hundred (10 2), +99 can be used instead of 1.
These positive numbers mentioned above are the "complements of negative numbers".
The formula for finding the complement is: Complement (i.e. positive) = negative + period.
Positive numbers must be directly involved in the operation, and no further transformations can be made.
That is to say: a positive number is already a positive number in itself, and it does not have any complements.
Computers use binary, which is called "complement".
8-bit binary, with its period, is: 2 8 = 256.
8-bit binary, for a total of 256**.
Half of them (i.e. 128) represent the negative number: 1 128.
Then, the complement of 1 is:1 + 256 = 255 = 1111 1111 (binary).
The complement of 2 is: 2 + 256 = 254 = 1111 1110.
The complement of 128 is: 128 = 1000 0000.
Stupid
At this point, you can launch the "Definition of Complement":
When x >=0, [x] complement = x; Zeros and positive numbers do not need to be transformed.
When x < 0, [x] complement = x + 2 n. n is the number of bits of the complement.
This is the universal formula.
In a more rigorous book, there is also this formula, you go and flip through the book.
It is extremely easy to find the complement according to the formula, and you can understand the meaning of the complement.
It is also very convenient to find the value represented by the complement.
Then, don't learn "the original code is reversed, and the symbol bit is added unchanged".
Only those foreigners who are not good at math do these "separate road" tricks.
In fact, as long as there is a "complement and value" interchange, it is enough.
Eq. 5 7 = 2, and the computer uses the eight-digit complement calculation band to bend as follows:
7] Complement =
Summing: (1).= [2] Complement.
Discarding the carrying, the result is correct.
Regarding the original code and the reverse complement, you can borrow this book. >>>More
Original code: 10001101
Reverse code: 11110010 >>>More
in the computer system.
, numeric values, all with complements. >>>More
The binary positive number of the original code is the reverse complement of the codeWhy the same? >>>More
Three types of representations for the number of machines were introduced: the original code, the complement code, and the inverse code, which encoded the sign bit and the numeric bit together, and the original value corresponding to the number of machines was called the true value 1 Original code notation In the original code notation method, the value is expressed as an absolute value, and the leftmost part of the value is represented by "0" and "1" to represent positive and negative numbers respectively, and is written as [x] The original code representing x. For example, in an 8-bit binary number, the original codes of the decimal numbers 23 and -23 are represented as: >>>More