#include<stdio.h>
int main()
{
unsigned short int x=-10;
short int y=-10;
unsigned int z=-10000000;
int m=-10000000;
printf("x=%d y=%d z=%d m=%d",x,y,z,m);
return 0;
}
输出不同= x=65526 y=-10 z=-10000000 m=-10000000
如何无符号短整数从unsigned int的
我的查询是如何在unsigned short int
保持数据的场景从unsigned int
不同。即x=65526 where as z=-10000000 why x is not equal -10 where as z can hold any data
作为短是2字节,以便twos complement -10 is 65526
但为什么不能在的z
http://stackoverflow.com/questions/3812022/what-is-a-difference-between-unsigned-int-and-signed-int-in-c – Rulisp
'sizeof(unsigned short int)'和'sizeof (unsigned int)' –