Soft test road-the world of code, soft test road

Source: Internet
Author: User

Soft test road-the world of code, soft test road

After taking the soft test, I first came into contact with the knowledge of computer systems. It mainly introduced the structure and principles of computers, which are very abstract.

We all know that operations on computers are performed in binary format. However, since there is only an addition generator in the computer, subtraction operations may often fail, this requires us to convert the subtraction operation to the addition operation. As a result, various codes appear.

1. Original code

The original code is the absolute value of the symbol bit plus the true value, that is, the first digit represents the symbol, and the other digits represent the value. For example, if it is an 8-bit binary:
[+ 1] original = 0000 0001

[-1] original = 1000 0001
The original code is the easiest way for the human brain to understand and calculate.

2. The expression of the anticode is as follows: the anticode of a positive number is itself, the anticode of a negative number is based on the original code, the symbol bit remains unchanged, and the rest of the digits are reversed.
[+ 1] = [00000001] original = [00000001]-
[-1] = [10000001] original = [11111110] Reverse
It can be seen that if an anticode represents a negative number, the human brain cannot intuitively see its value. It is usually converted to the original code and then computed.
Inverse code: solves the problem of adding negative numbers. It converts subtraction to addition to simplify calculation rules;
3. the expression of the complement code is: positive complement is itself, negative complement is based on the original code, the symbol bit remains unchanged, the rest of you take the reverse, and finally + 1. (+ 1 on the basis of the anti-code)
[+ 1] = [00000001] original = [00000001] inverse = [00000001] Complement
[-1] = [10000001] original = [11111110] = [11111111]
For negative numbers, the human brain cannot directly see the value of the complement expression. It is usually necessary to convert the value to the original code to calculate its value.

PS: Another simple method for converting the original code to the complement code: the value part is searched from the low position to the high position, and the first 1 and its right 0 remain unchanged, bitwise inversion on the left of the first 1.

Complement: solves the problem of positive and negative zeros in negative addition operations, and makes up for the lack of anticode.

4. Code Transfer

The expression of the QR code: no matter whether it is positive or negative, you only need to reverse the signed bits of its complement code.
[+ 1] = [00000001] original = [00000001] = [00000001] fill = [10000001] shift
[-1] = [10000001] original = [11111110] = [11111111] fill = [01111111] shift

 Summary:

1. The original code, complement code, and reverse code of positive numbers are all themselves;

2. Original code, complement code, and anti-code formula of negative (Binary:
Reverse code = original code (except the symbol bit)
Complement = reverse code + 1
Anti-code = complement-1
Shift code = complement sign bit reverse

3. In the binary number, the sum of the complement codes of the two numbers is equal to the complement codes of the two numbers.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.