Previous: http://www.bkjia.com/kf/201202/121049.html
I.
When a fixed number of points are stored in the memory, the highest bit (the leftmost bit) indicates the number symbol, 0 indicates positive, and 1 indicates negative. The value is stored as a complement. A positive complement is the binary number of The number. The following method is used to obtain a negative complement:
(1) first take the absolute value of the number
(2) store the data in binary format.
(3) reverse it.
(4) then add 1
The maximum bitwise of the binary complement of all negative numbers must be 1.
Obviously, the maximum value of an unsigned positive number is about twice the maximum value of a signed positive number plus 1 (because the complement code has positive 0 and negative 0 ). In C language, real numbers (floating point type) are signed and do not use unsigned modifiers.
II.
Length of common data types: (1B = 8bit)
Char: 1B
Short: 2B
Int: 4B
Long: 4B
Float: 4B
Double: 8B
Long: 8B
III.
Character-type data is stored in the memory with the corresponding ASCII code.
4.
Print the RMB symbol printf ("Y \ B = \ n"); control code "\ B" to return the print header to one cell, return the printed Y position, and then print the character "= ", the two characters overlap to form the renminbi symbol. Of course, this output can only be implemented on the printer, not on the monitor. Because the display does not have the overlapping display function.
5.
After a variable is displayed and converted, data of another type is obtained, but the type of the original variable remains unchanged.
6.
The Printf () function is generally in the following format:
Int printf (format control string, output expression 1, output expression 2 ,...);
A format control string consists of two parts: a format description field and a common character. Common characters (including escape character sequences) are simply copied and displayed. A format description field leads to conversion and display of an output parameter item. It is a format description field derived from "%. Format description: The fields must be consistent with the output expression parameters.
% Prefix modifier domain width Precision Length modifier format code
-, 0, +, space, # A decimal integer.
It should be pointed out that the actual precision of output data does not mainly depend on the field width and precision in the format description, nor on the accuracy of input data, but mainly on the storage precision of data in the machine. For example, the C language system can only provide 6 Valid numbers for float data. The format indicates that the width of the specified field is greater than that of the field, and the precision is longer than that of the field. The number on the excess digits is meaningless. Therefore, increasing the domain width and precision does not increase the actual precision of the output data.
7.
A problem that plagued me that year
# Include <stdio. h>
Int mian (void)
{
Int a = 1, B = 2;
Printf ("x = % d, y = % d \ n", ++ a + B, ++ B + );
Return 0;
}
The program execution result is x = 5, y = 4
The reason is that the operation order of the output expression in the printf () function is from right to left. However, it should be noted that this rule varies depending on the program to be compiled. Therefore, we try to make sure that the output expressions do not affect each other during the output, but they must be a fixed value.
8.
When inputting data, instead of inputting a data item, it is actually sent to a variable. Instead, it is input only after entering a line of characters and pressing enter. This line of characters is first stored in a buffer zone, then read data from the buffer according to the scanf () format description. If the input data exceeds the number required by one scanf () lock, the remaining data will be used as the next scanf () then use. To maintain input consistency, you can add explicit white spaces in different types of transformations in the format string. Scanf ("% d % c % d % lf", & num, & name, & sex, & age, & salary );
When the field width is defined, scanf () will pick up characters in the input stream in the buffer according to the width interval.
Scanf ("% 3c % 3c", & c, & d); if we enter abcd, c = a, d = d;
9.
When getchar () is executed, a character is displayed every time a character is read, but not a character is input from the keyboard. This character is immediately sent to a character variable, instead, wait until you press Enter to input a line of characters into the buffer, and then the getchar () function takes a character from the buffer and sends it to a variable of the variable type. In this case, it becomes a row buffer.
Excerpted from a stray calf