Source code, anti-code, complement code, personal understanding, anti-Code complement

Source: Internet
Author: User

Source code, anti-code, complement code, personal understanding, anti-Code complement

Original code:

Binary Fixed-point notation, that is, the highest bit is the symbol bit, "0" indicates a positive number, "1" indicates a negative number, and the remaining bit indicates the value size.

The maximum digit of a positive number is 0.

The maximum digit of a negative number is 1.

Example:

Symbol bit value

+ 7 0 0000111

-7 1 0000111

Anti-code:

The reverse code of a positive number is the same as the original code, and there is no change

Negative Inverse code: it remains the same as the original symbol bit, and other values are reversed, that is, 0 is changed to 1, 1 is changed to 0.

Example:

Symbol bit value

+ 7 0 0000111

-7 1 1111000

Complement:

The positive complement code is the same as the original code, and there is no change

The complement of negative numbers is based on the anticode plus 1

Example:

Symbol bit value

+ 7 0 0000111

-7 1 1111001

 

Summary:

Why is the range of a byte-128 ~ 127

One byte is 8 bits, that is, 00000000 (8 bits)

To distinguish between positive and negative numbers, a computer occupies a sign bit to indicate positive and negative, so the maximum number can only represent 1111111 (7 digits ),

The binary 1111111 is converted to the 10th hexadecimal notation + 127.

 

Ask... I understand it, right?

 

 

 

Related Article

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.