Char is unsigned, short is signed.
So while they are both 2-byte long, they use the sixteenth bit for different purposes.
The range of the char type is 0 to 2^16 - 1 (0 to 65535).
The short range is -2^15 to 2^15 - 1 (?32,768 to 32,767).
char和short在內(nèi)存中所占大小一樣,都是16位锨用。但是short有一位符號位泵殴。所以范圍是0 ~ 2^16 - 1 (0 ~ 65535)汹想。而char沒有符號位。所以char的范圍是-2^15 ~ 2^15 - 1 (?32,768 ~ 32,767).