Actually, this range only applies to 16-bit compilers such as Turbo C.
Incorrect. That range is the guaranteed minimum specified in the language standard, and it applies to all compilers. You're free to expect a larger range than that, but then you'd be depending on the compiler rather than the standard.
If you assume that int
is 32 bits, for example, your code is technically not portable. If you assume that int
is 16-bits two's complement (ie. you get an extra step on the negative range), your code is technically not portable.
The advice to jump from int
to long
when exceeding the range of [-32767,+32767] is spot on.