A review of computer numerical storage Method-original code, anti-code, complement

Source: Internet
Author: User

Suddenly thought of the computer's complement, now use this topic to review the relevant knowledge points

unsigned char ch =-1;

int val = ch;

The final value of Val is 255;

Converted to binary,-1 Source: 1000 0001, anti-code: 1111 1110, negative numbers in the computer is in the form of complement, 1 of the complement: 1111 1111

CH variable is unsigned, that is, the entire complement of bits are numeric digits, 1111 11,112 binary bits converted to decimal is 255, the final assignment to the integer result is naturally 255

This topic examines the computer numerical storage, for positive numbers, anti-code and complement is the same itself, for negative numbers, a little difference

Negative number of the inverse code: the original code based on the symbol bit unchanged, the value is reversed

Complement of negative numbers: Anti-code based on +1

A review of computer numerical storage Method-original code, anti-code, complement

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.