1. Original code
+7 of the original code is 0000 0111
-7 of the original code is 0111
+0 of the original code is 0000 0000
-0 of the original code is 0000
2. Anti-code
A number if the value is positive, then the inverse code and the original code are the same.
If a number is negative, then the sign bit is 1, others are opposite to the original code
+7 Anti-code 0000 0111
-7 Anti-code 1111
-0 Anti-code 1111 1111
3. Complement
The original code and anti-code are not conducive to computer operations, such as: 7 and 7 of the original code to add, but also need to determine the symbol bit.
Positive number: The original code, the anti-code complement are the same
Negative number: The highest bit is 1, the rest of the original code to reverse, and finally to the whole numbers + 1
-7 of the complement:=
0111(original code)
1111(anti-code)
1111 1001 ( complement )
+0 's complement is 00000000
-0 's complement is also 00000000
According to the complement of the negative number of the original code: the complement sign bit unchanged, the other bits to reverse, the last total of 1, get the original code
With the complement of the arithmetic, subtraction can be achieved by addition |
7-6=1 7 complement and -6 complement:00000111 + 11111010 = 100000001 After the carry is abandoned, the remaining 00000001 is the 1 complement |
-7+6 =-1 -7 complement and 6 complement:11111001 + 00000110 = 11111111 11111111 is --1 's complement. |
4.sizeof keywords
sizeof is not a function, so you do not need to include any header files to calculate the size of a data type, in units of:BYTE
In fact, C language does not specify the size of the specific data type, so the actual size of the data type and system is closely related, but the same system, the same data type size must be the same.
The size_t type is unsigned int under the four-bit operating system , which is an unsigned integer. when we write a program to deal with an impossible negative value, it is generally used as an unsigned number , so that the maximum number of expressions can be increased.
C Language Basics (4)-Original code, anti-code, complement and sizeof keywords