Assembly language primitive, inverse, and complement, and truth value problems

1. The truth value of a number is the size of the original representation of that number. The binary truth value, is the binary representation of the truth value.

For example, -2, the binary truth value is -10B.

2. Yes. [X]-complement + [Y]-complement = [X+Y]-complement

3. The complement of a positive number is its original code;

for a negative number, subtracting the complement by 1 and inverting it by bit can compute the original code

inverting the complement by bit and adding 1 can compute the original code as well

both methods produce the same result.

For example, in the 8-bit case, the complement of -2 is 11111110,

with the first method:

Subtract one: 11111110-1=11111101

Invert it: 10000010—2

with the Second method:

Take the inverse: 10000001

Add one: 10000010 — 2

### Do you know how to find the truth value of the complement?

The steps to find the truth of Patch are as follows:

If the highest bit of Patch is 0, then the original code is Patch, then the truth is the corresponding decimal value.

If the highest bit of the complement is 1, then the original code is the inverse of the complement + 1, and the truth value is the opposite of the corresponding decimal value.

If the complement is 0101, then the true value is 4+1=5.

If the complement is 1010, then the inverse code is 0101, and after +1 it is 0110, so the corresponding decimal value is 4+2=6, so the true value is -6.

Two’scomplement (two’scomplement) is introduced as follows:

1, In computer systems, numerical values are always represented (stored) by complements.

The main reason: using the complement, the sign bit and the other bits can be handled uniformly; at the same time, subtraction can be handled as addition. In addition, when two numbers expressed in complement are added, if there is a rounding in the highest bit (sign bit), the rounding is discarded.

2. The conversion process between complementary and original codes is almost the same.

### Complement, source, inverse, truth conversion solved

In computer systems, numerical values, invariably, are represented and stored in complementary codes.

Both source and inverse codes are encoded in such a way that they do not make sense.

A zero, they both coded two codes: -0, +0.

So, this code, does not have a computational function.

In computers, the original code and the inverse code, do not exist.

The so-called “inverse plus one” is also impossible to realize.

True value and complement can be directly converted to each other.

Their correspondence is as follows:

Just remember: [the first complement is negative] this feature, you can.

——— ———- ——-

When the code is 8 bits long, -128 inverse of the original code, are not exist.

However, -128 does have a complement of 10000000.

At this time, it is not possible to convert the “original code inverse code plus one” to smallpox.

It is also not possible to convert to the complement of the code.

### How to convert both complement and truth value?

1. Conversion of the original code to the true value

Based on the definition of the original code, the original code of the value of each bit according to the weight of the expansion, summing, by the sign bit to determine the number of positive and negative, you can be from the original code to find the true value of the number.

Example: It is known that \[x\] original = 00011111B, \[y\] original = 10011101B, find x and y.

Solution:

x=+(0×26+0×25+1×24+1×23+1×22+1×21+1×20)=31

y=-(0×26+0×25+1 ×x24+1×23+1×22+0×21+1×20)=-29

2. Inverse code to truth

If the truth value of the inverse code is required, it is sufficient to find out the original code corresponding to the inverse code, and then convert the original code to the truth value according to the above method of original code to truth value to find out the truth value of the number.

The original code of a positive number is the inverse code itself. Negative numbers can be based on the inverse code, keeping the sign bit unchanged at 1, and inverting the numeric bit by bit.

Example: It is known that \[x\] inverse = 00001111B and \[y\] inverse = 11100101B, find x and y.

Solution: \[x\] original = \[x\] inverse = 00001111B, then

x = +(0×26 + 0×25 + 0×24 + 1×23 + 1×22 + 1×21 + 1×20) =15

\[y\] originally = 10011010B, then

y=+(0×26+0×25+1×24+1×23+0×22+1×21+0×20)=-26

3. Conversion of the complement to the truth

If you want to find out the truth value of the complement, you must also find out the original code corresponding to the complement first. Positive numbers have the same original code as the complement. For negative numbers, the complement of the original code can be found again, i.e., \[x\]original = \[\[x\]complement\]complement.

Example: If it is known that \[x\] complement = 00001111B and \[y\] complement = 11100101B, find x and y.

Solution: \[x\] original = \[x\] complement = 00001111B, then

x=+(0×26+0×25+0×24+1×23+1×22+1×21+1×20) =15

\[y\]original=\[\[y\]complement\]complement=10011011B, then

y=-(0×26+0×25+1×24+1×23+0×22+1×21+1×20)=-27

1.Original code:

(1). Introduction:

Original code (trueform) is a computerized representation of the binary fixed point of a number. The original code is the code obtained by adding the sign bit to the left of a binary number, and when the binary number is greater than 0, the sign bit is 0; when the binary number is less than 0, the sign bit is 1; and when the binary number is equal to 0, the sign bit can be 0 or 1.

(2). Coding method:

The original code is the simplest way to encode signed numbers, easy to input and output, but more complex as a code addition and subtraction operations. A word length of n machine number can represent the number of different numbers is fixed 2^n, n = 8 when 2^n = 256; used to represent the signed number, the number of the range is -(2^(n-1)-1) ~ +2^(n-1)-1, n = 8 is the range is -127 ~ +127. but in the case of not need to take into account the positive and negative of the number, there is no need to use a bit to represent the sign bit, n Bit machine number all used to indicate that is the value of the number, then the range of the number is 0 ~ 2^n-1, n = 8 is this range is 0 ~ 255. no sign bit of the number, called the unsigned number.

2. True value:

Introduction:

True value is the true value, under certain conditions, the measured objective existence of the actual value. The true value is usually an unknown quantity, generally speaking, the true value refers to the theoretical true value, the specified true value, relative true value.

Theoretical true value is also called the absolute true value, such as the triangle angle and 180 degrees.

The agreed true value, also known as the specified true value, is a value close to the true value, it is negligible difference with the true value. In practice, the average of enough measurements without systematic error is taken as the agreed value.

Relative truth is when the indicated value of a higher standard is the true value of the next level, which is called the relative truth.

In computer numerical representation, the form in which data is expressed in terms of a plus or minus sign plus an absolute value is referred to as “truth value”.

The ideal value of the exact number [quantity] of values of a quantity or definite object under the instantaneous conditions under which it is observed. Note: Such a value can only be attained when all causes of error have been eliminated or when the total number of objects is infinite. In cases where the total number of objects is finite, the complete total must be considered.

### Knowing that [X] original=10110101,find the truth value X and the complement and inverse of X

[X]inverse=11001010, (leave the sign bit untouched and invert the lower 7 bits of the original code of X bit by bit).

[X]complement=11001011 (add 1 to the inverse of X).

Computer machine number in the simplest form, the numerical value of the bit is the absolute value of the true value, the sign bit bit “0” when the number of positive, sign bit “1” when the number of negative, the original code is also known as the absolute value of the sign.

In order to facilitate the distinction between integers and decimals, the integer sign bit and the numerical value of the bit with “,” separated from the decimal sign bit and the numerical value of the bit with “.” between the sign and value places of integers, and “.” between the sign and value places of decimals.

Extended information:

Inverse codes are usually transition codes used to find the complement from the original code or the original code from the complement. According to the definition, you can get the inverse code of the machine number of the integer and decimal “0” in the representation of each of the two forms, “+0” and “-0” are not the same, to the 8-bit machine number as an example, the “+0” of the integer and “-0” of the decimal are not the same. “+0” original code is 0.0000000, the inverse code is 0.0000000; the decimal “-0” original code is 1.0000000, the decimal “-0” The inverse code is 1.1111111. The inverse code is the same as the original code when it is a positive number; when it is a negative number, the inverse code is the original code except for the sign bit, and the other bits are inverted according to the bit.