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.

CategoryType specifiers
KindKeyword / Statement
C standardC89 / 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 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.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏