Finding maximum value of a short int variable in C
问题 I was working on Exercise 2-1 of K&R, the goal is to calculate the range of different variable types, bellow is my function to calculate the maximum value a short int can contain: short int max_short(void) { short int i = 1, j = 0, k = 0; while (i > k) { k = i; if (((short int)2 * i) > (short int)0) i *= 2; else { j = i; while (i + j <= (short int)0) j /= 2; i += j; } } return i; } My problem is that the returned value by this function is: -32768 which is obviously wrong since I'm expecting a