Search code examples
c++standards

What is the minimum size of an int in C++?


Cppreference.com claims:

If no length modifiers are present, it's guaranteed to have a width of at least 16 bits.

However, the latest standard draft only says:

Plain ints have the natural size suggested by the architecture of the execution environment.

With the footnote only adding that:

int must also be large enough to contain any value in the range [INT_­MIN, INT_­MAX], as defined in the header <climits>.

From these sections of the standards, it seems like int's size is entirely implementation dependent. Where does the "16 bit minimum" guarantee come from?


Solution

  • The minimum size for int follows from the requirement that INT_MIN shall be no less than -32767 and INT_MAX shall be at least +32767. Note that that's 2^16-1 possible values, which allows for 1's complement with signed zero representation.