C language basic source code inverse code complement and move code details

  • 2020-05-12 02:59:53
  • OfStack

The function of original code, inverse code, complement code, shift code?

In a computer, the division of the number of machines into unsigned and signed Numbers. An unsigned number represents a positive number, and there is no sign bit in the number of machines. Is located in the unsigned number, if the decimal point is agreed after the lowest point of the machine number, it is a pure integer; If the decimal point is before the highest point of the machine number, it is a pure decimal. For signed Numbers, the highest bit of the machine number is the positive and negative sign bit, and the rest is the value. If the position of the decimal point is after the lowest value of the machine number, it is a pure integer. If the decimal point is placed before (and after) the highest value of the machine number, it is a pure decimal.

In order to facilitate calculation, the number of machines with sign bit can be coded by different coding methods such as source code, inverse code and complement code, which are called code system.

How to express the original code, inverse code, complement code and shift code?

Example: [+45] original = 00101101-45 =10101101 (all the following examples are the transformation of these two Numbers)

The original code:

The source code representation adds a sign bit (that is, the highest bit is the sign bit) in front of the value: the positive bit is 0, the negative bit is 1 (there are two ways to represent 0: +0 and -0), and the remaining bit represents the value.

Example: [+45] original =00101101 [-45] original =10101101

Inverse code: inverse code is a kind of numerical storage, but because the complement code can more effectively represent the number in the form of the computer, so most computers do not use inverse code to represent the number.

The negative code notation provides that the negative code of a positive number is the same as the original code. The inverse of a negative number is to invert the original code bit by bit, except for the sign bit.

For example: [+45] =00101101 [-45] =11010010

Complement: in a computer system, the number 1 law is represented and stored as a complement. The reason is that, with the complement code, the symbol bit and the number range can be unified 1 processing; At the same time, addition and subtraction can also be unified 1 processing. In addition, the complementary code and the original code mutual conversion, its operation process is the same, no additional hardware circuit.

The negative code representation provides that the complement of a positive number is the same as its original code. 1 simple way, the sign bit remains the same as 1, the value bit remains the same from the first 1 on the right and the 0 on the right, and the left side is inverted by bit. You can also derive the complement from the negative, which is to add 1 to the negative.

For example: [+45] tonic =00101101 [-45] tonic =11010011

Move the code:

Move code (also known as the code) is the sign bit to take the complement, 1 is used as the order of floating point Numbers, introduced to ensure that the floating point number of the machine zero is all zero. This one is neither positive nor negative.

For example: [+45] shift =10101101 [-45] shift =01010011

The above is the original code of the machine code, the inverse code, the complement code and the move code representation method, in fact, these representations are to make the computer operation more convenient.

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: