Skip to content
doubtly

2 answers

It depends on the size of int: with a 2-byte (16-bit) int, 32768 cannot be stored; with a 4-byte (32-bit) int, as in GCC and most modern compilers, it can.

A signed integer of \(n\) bits stores values from \(-2^{n-1}\) to \(2^{n-1}-1\).

  • 16-bit int (old Turbo C): range \(-2^{15}\) to \(2^{15}-1\), i.e. \(-32768\) to \(32767\). 32768 is one more than the maximum, so it overflows (it would typically wrap around to \(-32768\)).
  • 32-bit int: range \(-2147483648\) to \(2147483647\), so 32768 is stored without any problem.

The C standard only guarantees that int can hold at least \(-32767\) to \(32767\). So for portable code that must store 32768, use long int (at least 32 bits) or unsigned int (at least 0 to 65535). You can check the limits on your compiler with INT_MAX from <limits.h> or sizeof(int).

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.