int Basic signed integer type
int Basic signed integer type
int is a signed integer, commonly 32 bits but guaranteed only -32767..32767. See INT_MIN and INT_MAX; signed overflow is undefined, and signed is implicit.
| Category | Type specifiers |
|---|---|
| Kind | Keyword / Statement |
| C standard | C89 / C90 |
📝 Syntax
int n = 42;
▶ Example
Edit the C code below and click Run; the server compiles and executes it:
Output:
value + 2 = 42
INT_MIN < 0 = 1
🏷️ Related type specifiers
📚 Related Tutorials
❓ FAQ
QIs int always 32 bits?
ANo. The standard guarantees only a minimum range. Some historical and embedded environments use 16-bit int, while other implementations may be wider. Use sizeof, CHAR_BIT, INT_MAX, and related macros to inspect the target implementation.
QDoes signed int overflow wrap to zero like unsigned arithmetic?
ANo such guarantee exists. Signed integer overflow is undefined behavior, and compilers may optimize based on that assumption. Use a suitable unsigned type when modular wraparound is required.
QAre int and signed int different types?
ANo. They denote exactly the same signed integer type; signed merely makes the default semantics explicit. Plain char is different, so this conclusion cannot be extended to char.