1. Signed number and unsigned number
The signed number is the highest bit ,0 for Positive, and1 for negative .
The highest bit of unsigned number is not a sign bit , but a part of a number.
1011 1111 0000 1111 1111 0000 1011 1010 If there is a symbolic number to look at, then he is a negative complement, if when viewed as an unsigned number, he is a positive source code
Unsigned number minimum is 0, cannot be negative
To define an unsigned int
unsigned int A; An unsigned int variable is defined using unsigned int, named a
Short,long,long long, unsigned int
Short is a shorter integer that is generally half the size of int bit of Windows is 2 bytes
What is the maximum number of hexadecimal digits that can be stored in short? 7fff
When a small data type is assigned to a large data type, there is no error, because the compiler converts it automatically, but when a large type is assigned to a small data type, it is possible to lose a high position.
Longis a long integer type,Longthe size of the change is much more, in +bit ofWindowsNext is4bytes, in -bit ofWindowsis a4of bytesIn +bit ofLinuxis a4 bytes , in -bit ofLinuxis a8 bytes 。
Long length integer,longlong 8 bytes in both the system and the system
Unsigned int,unsigned short, unsigned long, unsigned long long
The default is int,100L represents a long type of constant, and100LL represents Long Long Constants of type
100U represents a constant of type unsigned int , if you want to express a unsigned long long constant , 100ull
9l,9l,9ll,9ll,9u,9ull,9ull
2. printf output int Value
%d is the output of a signed, ten - binary int type
%o, output 8 binary int
%x, Output The int of the Binary
%x, Output the int. int, but ABCD These all use uppercase letters
%u, output an unsigned number of ten binary
%p output memory address
3. Big-endian alignment and small-end alignment
What is the smallest unit of memory in your computer? Is a byte,and a data type greater than byte is stored in memory in order of precedence.
high memory address put an integer high, low memory address put an integer low, this way called to put, the term is called small end alignment . Both X86 and ARM are small-aligned.
high memory address put an integer low, lower memory address put an integer high , this way is called positive, the term is called big- endian alignment , many unix server CPU is the big-endian alignment.
Define a variable A of type int, and under vs you can see how it is arranged in memory as follows:
Indicates that the Windows system is small-aligned.
C Language Foundation (5)-Signed number, unsigned number, printf, size end alignment