Original code, anti-code, complement

Source: Internet
Author: User

Anti-code, complement and the original code these concepts:

(1) The representation of the numeric data  
          We refer to a binary form represented by a number in a computer as the number of machines, This number is called the true value of this machine number. The number of machines has a fixed number of digits, in particular how many bits are related to the machine, usually 8-bit or 16-bit. The number of machines to digitize the symbol of truth, usually with the highest-level representation of the symbol, 0 is positive, 1 means negative. For example, assuming that the number of machines is 8 bits and the highest bit is the sign bit, then in the case of fixed-point integers, the true values of 00101110 and 10010011 are decimal numbers +46 and-19, respectively.  
    (2) Original code:  
     The original code of an integer means: The sign bit is denoted by 0 or 1, 0 means positive, 1 is negative, The numeric part is the binary representation of the absolute value of the integer.  
For example: Assuming that the number of machines is 8, then: [+17] Original =00010001 [-39] Original =10100111
It is worth noting that the original code of the number 0 is not unique, there are "positive zero" and "negative 0" points.  
    (3) anti-code  
      in the representation of the inverse code, positive numbers are represented in the same way as the original code The inverse of a negative number is the inverse of its original code except for the sign bit (i.e., 0 change to 0). In general, the inverse of x is represented by [x]. Example:  
[+45] anti = [+45] original = 00101101
[-32] original = 10100000
[-32] reverse = 11011111
    (4) complement  
      in the complement representation, positive numbers are represented in the same way as the original code, and the complement of negative numbers adds 1 to the least significant bit of their inverse code. The complement of X is usually indicated by [x]. For example:  
[+14] complement = 10100100
[-36] anti = 11011011
[-36] complement = 11011100 

A binary representation of a number in a computer, called the number of machines. The number of machines is signed, in the computer with a number of the highest bit of the symbol, positive 0, negative number is 1. For example, the number +2 in decimal, the computer word length is 8 bits, the conversion to binary is [00000010]. If it is-2, it is [10000010]. Because the first bit is the sign bit, the form value of the machine number is not equal to the true value. For example, the above signed number [10000010], its highest bit 1 is negative, its true value is-2 instead of the form value 130 ([10000010] converted to decimal equals 130). So the true value of the number of machines with the sign bit is called the truth of the machine number.

Original code, anti-code, complement

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.