Article Directory
In-depth analysis of data storage in memory (integer)
type of data
Introduction to data types
See in the previous blog, this is the basic content, so I won't talk about it here.
https://blog.csdn.net/weixin_43580319/article/details/110249779
The meaning of data types
1. Use this type to open up the size of the space, the size and the range of different types of open up are different, the size of the opened memory space determines the range of use.
2. How to look at the perspective of memory space.
Integer type classification
char
unsigned char
signed char
short
unsigned short [int]
signed short [int]
int
unsigned int
signed int
long
unsigned long [int]
signed long [int]
Integer storage in memory
The content of this part requires us to first understand the content of the original code, the inverse code, and the complement. The basic knowledge of this part is relatively simple, and you can refer to the articles written before. https://blog.csdn.net/weixin_43580319/article/details/110913037
Big and small
definition
Big-endian (storage) mode means that the low bits of data are stored in the high addresses of the memory, and the high bits of data are stored in the low addresses of the memory.
Little-endian (storage) mode means that the low bits of data are stored in the low addresses of the memory, and the low bits of data are stored in the high addresses of the memory.
As shown above, this block uses little endian (storage) mode
Baidu 2015 system engineer written test
int jugeSystem()
{
int val = 1;
char ch = val;//隐式类型转换,大给小的->截断
//小的给大的->提升
if (ch == 0x01)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
if (jugeSystem())
{
printf("小端");
}
else
{
printf("大端");
}
return 0;
}