### Multiple choice questions in c language to solve!

27.B28.D29.A30.A31.C33.D

27.-48 in the 48 converted to binary is 11000000, a byte is eight bits, due to the negative number of the highest bit is 1, then the original code of -48 is 10110000, and then converted to the inverse of the code of the highest bit is unchanged (or 1), the other bits of 0->1,1 ->0, the inverse code is 11001111, the inverse code in the addition of 1 to the complement is 11010000

28. District code 0915, the first two as a group, the last two as a group, respectively, into hexadecimal, (09)10-> (09)16,

(15)10-> (0F)16, in each group, respectively, plus 20H,09->29,0F->2F,so converted to the international code is 292FH

29. [X] complement = 10110100, because the highest bit is 1, so it is a negative number converted to the original code will be the first minus 1, in addition to the first bit will be replaced by 0 for 1, 1 for 0, the original code for [X] is 11001100, which can be seen as- 1001100, [Y] complement = 01101010, so y is positive then the original code is complementary code, the original code is 01101010, that (x-y) = (-1001100-1101010) = – (1001100 + 1101010) = -10010110, and because a byte is only 8 bits, and the highest bit to indicate the positive and negative, so the overflowed

30. I don’t know the last two of this question, 00111001 is the inverse code, because the highest bit is 0, so it’s a positive inverse code is the original code, that 00111001 = 2^5 + 2^4 + 2^3 + 2^1 = 57

31. This is to be their own calculations, but you can find that the B, C options are 76, due to the decimal system is ten A5=10*16+5=165, (140)11=1*121+4*11=165

I don’t know if you can read it,

Positive numbers are the same regardless of whether they are original or inverse or complementary codes,

Negative numbers are the same regardless of whether they are original or inverse or complementary codes, the highest bit is 1,

Negative numbers are original or inverse, in addition to the highest bit of the code other than the highest bit of the code 1 to 0, 0 to 1,

Negative numbers complementary code is the inverse code +1.

You can go to the Baidu, there are all these

### What is the complement of decimal-48?

The complement of decimal-48 is 11010000.

The original code in a computer uses the highest bit to indicate the positive or negative of a number, with 1 being negative and 0 being positive. The highest bit is 1 negative integer original code for the complement, the original code in addition to the sign bit of all the bits of the inverse (0 to 1, 1 to 0, the sign bit for 1 unchanged) and then add 1, and finally add the sign bit.

The original code of decimal-48 is 10110000, and all the bits except the sign bit are 0110000, inverted to 1001111 , and then add 1 to 1010000, and bring the sign bit to 11010000.

Expanded:

Designing the complement code, the modulo operation is consciously cited in the mathematical automatic processing of sign bits, the natural processing of sign bits is achieved by using the automatic discarding of modes, and the desired requirements can be accomplished without changing the physical architecture of the machine simply by a change in encoding, so complementary codes have always been used.

The complementary code eliminates the non-uniqueness of the coded mappings in the representation of numbers by defining them artificially, forcing the converted 10,000,000 to be identified as -128. Of course, such a forced identification can be done for the original code and the inverse code as well.

### How to calculate the original code complement inverse code

How to calculate the original code complement inverse code

One, the positive integers of the original code, inverse code, complement code is exactly the same, that is, the sign bit is fixed to 0, the numerical value of the same bit.

Two, negative integer sign bit is fixed to 1, from the original code into the complement, the rules are as follows:

1, the original code sign bit 1 is unchanged, the integer binary digits of each inverse, get the inverse code.

2, the inverse code sign bit 1 unchanged, the inverse code value bit of the lowest bit plus 1, to get the complementary code.

Methods:

(1) Calculate the original code, inverse code and complement of a positive integer. [Sign bit is 0, original code=inverse code=complement]

(2) Calculate the original code, inverse code and complement of a negative integer, first find the original code, then the inverse code, and finally the complement.

(3) according to the complement of the truth, generally use the formula in the figure to calculate, the positive integer sign is +, negative integer sign is -, usually after completing the complement of the truth, you can press the steps 1, 2 simple inverse to see if the results are correct.

Extended information:

Representation of the complement:

The concept of modulus: a unit of measurement is called a modulus or modulus. For example, a clock counts cycles in base 12, i.e., modulo 12. On a clock, the position of the hour hand remains unchanged by adding (forward dialing) an integer number of digits to 12 or subtracting (reverse dialing) an integer number of digits from 12. 14 o’clock becomes (p.m.) 2 o’clock after rounding off modulo 12 (14 = 14 – 12 = 2).

Dialing 10 frames counterclockwise from 0 o’clock means subtracting 10 hours, which can also be viewed as dialing 2 frames clockwise from 0 o’clock (plus 2 hours), i.e., 2 o’clock (0-10 = -10 = -10 + 12 = 2). Thus, with modulo 12, -10 can be mapped to +2. It follows that adding 2 has the same effect as subtracting 10 for a recurring system modulo 12.

So, in a system modulo 12, any operation that subtracts 10 can be replaced by adding 2, which converts the subtraction problem into an addition problem (note: computers have only adders in their hardware architecture, so most operations must eventually be converted to additions). 10 and 2 are complements of each other for modulo 12.

Similarly, the computer’s arithmetic components and registers are limited to a certain word length (assuming a word length of 8), so their operations are modulo arithmetic. When the counter reaches the full 8-bit limit, that is, 256 digits, it overflows and starts counting again from the beginning. The amount of overflow is the modulus of the counter, obviously, 8-bit binary number, its modulus is 2^8 = 256. In the calculation, the two complementary numbers are called “complementary code”.

### Original code inverse code complement formula and relationship

Original code inverse code complement formula and relationship are as follows:

Original code: the highest bit of the binary number indicates the sign bit, 0 indicates a positive number, 1 indicates a negative number, and the rest of the bits indicate the magnitude of the value.

Inverse code: the inverse code of a positive number is the same as the original code, and the inverse code of a negative number is the inverse of each bit of its original code except the sign bit.

Complement: the complement of a positive number is the same as the original code, and the complement of a negative number is the addition of 1 to its inverse.

Calculation formula:

Relationships:

The conversion relationship between the original code, inverse code, and complement is fixed, and it can be converted by the formula.

In computers, the complement is often used to represent signed integers because it simplifies the implementation of addition and subtraction.

When performing addition and subtraction operations, you can add the complements of two numbers and convert the resultant complements to the original code to get the correct result.

Original to Inverse: The inverse of a negative number is the inverse of each bit of its original code except the sign bit.

Inverse code to original code: the original code of negative number is to invert all the bits of its inverse code except the sign bit.

Inverse to complement: the complement of a negative number is the inverse of its inverse plus 1.

Complement to inverse: the inverse of a negative number is the complement minus 1.

Complement to prime: the prime of a negative number is the complement minus 1, and then inverted in all but the sign bit.

When performing bitwise operations, the result of the original, inverse, and complement are the same because bitwise operations involve only the magnitude of the value, not the sign bit.

In computers, the complement is usually used to represent signed integers because it avoids the occurrence of two zeros, +0 and -0, as well as overflow.

When performing multiplication, you need to multiply the complements of two numbers and then convert the resultant complement to the original code to get the correct result.

In short, the original code, the inverse code, the complement is the computer to represent the three ways of signed integers, they have a fixed conversion relationship between them, according to the need to convert each other. In practice, the complementary code is usually used to represent signed integers, because the complementary code can simplify the implementation of addition and subtraction to avoid the occurrence of two zeros, but also to avoid the occurrence of overflow.