当前位置:网站首页>Why is the hexadecimal printf output of C language sometimes with 0xff and sometimes not

Why is the hexadecimal printf output of C language sometimes with 0xff and sometimes not

2022-04-23 19:29:00 ToneChip

	unsigned short aaa = 0xC000;
	printf("0x%x \n", (aaa << 8) );

 Output  0xC00000

 Write another one like this 

	short aaa = 0xC000;
	printf("0x%x \n", (aaa << 8) );

 Output :0xFFC00000



This is because of the following short What is defined is a signed bit 16Bit, After moving left , It is also the corresponding signed int

版权声明
本文为[ToneChip]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231923488824.html