C语言-数据类型-整型

2021-05-29 16:03

阅读:611

标签:short   lan   符号   unsigned   十六   sizeof   clu   long   有符号   

#include 
int main (void)
{
	signed short int a1;//有符号short 
	unsigned short int a2;//无符号short 
	signed int b1;
	unsigned int b2;
	signed long int c1;
	unsigned long int c2;
	
	a1 = -32768;//无符号short -2^15~2^15
	a2 = 65535;//有符号short 0~2^16-1 
	b1 = -2147483648;//-2^31~2^31-1
	b2 = 4291967295;//0~2^32-1
	c1 = -2147483648;
	c2 = 4291967295;
	
	printf("%hd\n%d\n%d\n%u\n%ld\n%lu\n",a1,a2,b1,b2,c1,c2);
	printf("%o\n%d\n%X\n",9,11,10241024) ;//%o是以8进制输出,%d是以十进制输出,%x是以十六进制输出 
	
	printf("short:%d\nint:%d\nlong:%d\n",sizeof(a1),sizeof(b1),sizeof(c1));
	
	//short有符号用 %hd,无符号用%hu 
	//int有符号用%d,无符号用%u 
	//long有符号用%ld,无符号用%lu
	//long不小于int,int不小于short 
	return 0;
}

C语言-数据类型-整型

标签:short   lan   符号   unsigned   十六   sizeof   clu   long   有符号   

原文地址:https://www.cnblogs.com/Toff1024/p/14765770.html


评论


亲,登录后才可以留言!