C language integer variable

This article describes is a placeholder byte integer variable, and the range is how come

byte

储存单元的大小称为一个字节(byte)
字节是计算机储存容量的基本单位
每个字节由8个二进制位(bit)组成

Placeholder

占住一个位置表示这里有输入或者输出  %d  %f...
如下图绿色方框部分

Here Insert Picture Description

scanf是输入函数值
你用什么把占位符隔开的
你输入的时候就要用什么隔开
printf是输出函数
在双引号里你用什么把占位符隔开的  输出的时候就是用什么隔开
如下图

Here Insert Picture Description

Byte integer

int字节  有时编译器和系统的差异会导致int字节不同
如下图win系统int字节是4(原来是2byte)

Signed

有符号基本整型  int                 2字节  16
有符号短整型    shirt/short int2字节  16
有符号长整型    long/long int4字节  32

Unsigned

无符号基本型    unsigned        2字节   16
无符号短整型    unsigned short  2字节   16
无符号长整型    unsigned long   4字节   32

Here Insert Picture Description
Some people may forget sizeof operator (calculated byte)
look at the chart if you make recall
Here Insert Picture Description

Integer type Ranges
int -32768~32767
short -32768~32767
long -2147483648~2147483
unsigned int 0~65535
unsigned short 0~65535
unsigned long 0~4294967293
取值范围怎么来的(计算机用补码储存数据)short举例  16bit(2进制位)
0000000000000000~0111111111111111=2^15-1=32768
unsigned  short  16bit
0000000000000000~1111111111111111=2^16-1=65535

Difference between the two is
unsigned short originally stored symbol of a binary digit (bit) is used to store the data
and perhaps some people have seen unsigned long long

不用慌这只是给unsigned  long增加范围的
Published 22 original articles · won praise 40 · views 914

Guess you like

Origin blog.csdn.net/xlwhg/article/details/104165218