Original code, complement, anti-code

Source: Internet
Author: User

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

(1)representation of numeric data
I'mWe refer to the binary form represented in the computer as the number of machines, which is called the true value of this machine number. The number of machines has a fixed number of digits, specifically how many bits are related to the machine, usually8-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 refers to: the symbol bit is used0 or 1 means that 0 means positive, 1 is negative, and the value part is a binary representation of the absolute value of the integer.
For example, suppose that the number of bits in a machine is8, then: [+17] Original =00010001 [-39] Original =10100111
It is worth noting that due to theso the number0 of the original code is not unique, there are "positive zero" and "negative 0" of the points.
(3) Anti-code
in the anti-code representation, the positive number is the same as the original code, the inverse of the negative is the original code in addition to the symbol bit other than the counter (i.e.0 change to 0). In general, the inverse of x is represented by [x]. For example:
[+45] anti = [+45] original = 00101101
[-32] Original = 10100000
[-32] anti = 11011111
(4) Complement
In the complement representation, the positive number is expressed in the same way as the original code, and the complement of the negative number is added to the least significant bit of its inverse code .1. 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, complement, anti-code

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.