# Original code inverse code complement of -1010

### Calculation of binary complement

The first 1 of -1010 is not a flag bit

So to take the original code, you should put a 1 in front of it as a flag bit

11010

And then take the inverse of each digit except for the flag bit, that is, it’s the inverse code

10101

And then the inverse code is added 1

The final code is 10110, which is the inverse code. p>The final complement is 10110.

### Detailed overview of the original inverse complement

Original code:

The original code sign bit is where positive is 0 and negative is 1

Example:

34=00100010

-29=10011101

-19=10010011

Inverse code:

The inverse of a positive number is equal to the original,

Negative numbers: the sign bit is unchanged, the rest of the bits are inverted,

-33=10100001 (original)

11011110 (inverse)

-37=10100100 (original)

11011011 (inverse)

-49=10110001 (original)

11001110 (inverse)

Complement:

Data in the form of complement in the computer, the same in the form of complement is involved in the operation

Positive numbers: original = inverse = complement

Negative numbers: the inverse of the code that is obtained in the first place, the inverse code, plus one, is added in the lowest bit.

-34=10100010 Complement: 11011110

-29=10011101 Complement: 11100011

-47=10101111 Complement: 11011111

Why you need the inverse and complement?

Inverse code: calculator operators have only adders, not subtractors,

But inverse code has a flaw, positive and negative sums of 0 are not unique

Complement: to solve the case where inverse code positive and negative sums are not unique, a high overflow is used to solve it;

Example:

Complement: 45-19=26

00101101

+11101101

00011010

53-27=26

00110101

+11100101

00011010

65-34=31

01000001

+11011110

00011111

-34–27=-61

11011110

+11100101

—————————

11000011 Because his result is negative, you have to take his complement to get the correct result: 10111101

Positive numbers don’t need to be transferred, negative numbers need to have the complement of the negative number treated as the original code to find the complement, (the complement of the complement)

Examples:

111111111110000000 [-128 complement] to find the original code

1000000010000000

10010011 (original) 11101101 (complement)

### What’s the deal with computer primitive, inverse, and complementary codes? Can you give me an example?

What is the original, inverse, and complement of a computer?

Can you give an example?

In computers, there is no original or inverse code.

What’s the deal with complementary codes?

It starts with the “complement”.

The number of bits counted by a computer is fixed, as in an eight-bit machine.

After the number of digits is limited, you can use “complements” to replace negative numbers, and use addition to realize subtraction operations.

For example, two decimal digits, -1, can be replaced by +99.

25-1 = 24

25+99 = (one hundred) 24

The two algorithms function the same way by discarding the rounding, and taking only two digits.

99, is the complement of -1.　Formula: complement = one hundred + negative.

One hundred, is the counting period of two decimal numbers.

——— ———- ——

Computers use binary, complementary numbers, it is renamed: complement.

Octet binary: 00000000~11111111 (decimal 255).

The counting period is: 2^8=256.

So the -1’s complement is 256+(-1)=255=11111111 (binary).

This is the same result when you use the non-existent “inverse of the original code plus one”.

The formula for finding the complement of a negative number: period + that negative number.

Positive numbers, without conversion.　It can also be said that the positive number itself is the complement.

——— ———- ——

Can you give an example?

For example, 7-3 = 4.

The calculation with the complement is as follows:

7’s complement = 00000111

– 3’s complement = 11111101

– -Sum ——– —–

Gets (1) 00000100 = 4’s complement

Discard the rounding and keep only eight bits as the result, which realizes 7 – 3.

### What are the original, inverse, and complement of -x=-10?

The original, inverse, and complement of -10 are:

10001010 (original), 11110101 (inverse), and 11110110 (complement).

### The machine word length is 8 bits, then the -10 original inverse complement is

If the word length is 8 bits, then:

[-10]original=10001010b

[-10]inverse=11110101b

[-10]complement=11110110b

### How to represent -10’s prime, inverse and complement?

The original code of -10 is 10001010, the inverse code is 11110101, and the complement code is 11110110.

The sign bit of a negative number is 1, which means that the highest bit is 1, so when we say that the original code is the inverse code and the complement code, we have to limit the number of digits to be expressed. In simple terms, take eight bits for example:

The original code is the binary code of its own value, so -10=10001010.

The inverse code is inverted bit by bit, noting that the sign bit remains unchanged, so -10=11110101.

The complement adds one to the inverse, and -10=11110110.

Expansion Information

Advantages and disadvantages of the original code

1. Advantages

Simple and intuitive. For example, to represent a number in 8-bit binary, the original code for +11 is 00001011, and the original code for -11 is 10001011.

2. Disadvantages

The original code cannot take part in arithmetic directly, and it may be wrong. For example, in math, 1 + (-1) = 0, and in binary 00000001 + 10000001 = 10000010, converted to decimal -2, obviously wrong.

So the sign bit of the original code can’t be directly involved in the operation, it must be separated from the other bits, which increases the hardware overhead and complexity.