Binary, complement, and shift

Source: Internet
Author: User

In a computer, the number of symbols is represented by a complement.

1. Original code

The first digit of the original code is the symbol bit, and the other digits represent the value. For example, 8-bit binary:

[+ 1] original = 0000 0001

[-1] original = 1000 0001

2. Supplemental code

The positive complement is itself. The negative complement is based on the original code, and the symbol bit remains unchanged. The rest are reversed by + 1.

[+ 1] Complement = 0000 0001

[-1] Complement = 1111 1111

The rules for converting the complement code to the original code remain the symbol bit unchanged, and the rest will be reversed to + 1.

3. Shift

When the number of symbols is shifted, they are all shifted in the form of a complement code:

Shift right: discard the rightmost digit, and fill the leftmost sign bit.

Left shift: discard the leftmost part and add 0 to the rightmost part.

 

Binary, complement, and shift

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.