C++ signed int will take at least 16 bits of memory to hold and cannot be less than signed short int in any specific implementation; it can, however, differ from compiler to compiler. It usually gets stored as two's complement integer, but it is not a requirement of the standard. It is the standard way to represent an integer in C++, function
main returns int, even though in practice unsigned char would have been more than sufficient. An integer literal gets interpreted as int, unless followed by extra characters to symbolise that it's something else.
It can be shortened during declaration or conversion to signed or int, int being the most common.
int can safely store values -2¹⁵ – 2¹⁵-1, if the value gets too large or too small, a roll over can take place. While the fact of a roll over is a guarantee at some point, a coder cannot assume that it will happen in a specific place, INT_MIN and INT_MAX constants from <climits> library can be used to determine that. Many implementations push int into a 32-bit range.
Unlike the early versions of C (on which C++ is based) int is not a default type, in fact no default types exist at all.
Other C++ data types of the same size
- unsigned int
- char16_t or char32_t (depending upon implementation)
- short or long both can be equal to int, on most implementations at least one of them is.