I always thought that in C, int
stands for signed int
; but I have heard that this behavior is platform specific and in some platforms, int
is unsigned
by default. Is it true? What says the standard, and has it evolved over time?

- 133,132
- 16
- 183
- 261

- 38,438
- 19
- 134
- 183
-
1`char` is signed or unsigned and a different type than `signed char` and `unsigned char`. Maybe that's what you heard. But `int` is the same type as `signed int`. – bolov Jun 19 '17 at 08:20
-
"_but I have heard that this behavior is platform specific and in some platforms, `int` is `unsigned` by default_" - That's true for `char`. A `char` may be `signed` or `unsigned` by default – Spikatrix Jun 19 '17 at 08:20
-
@CoolGuy Oh, this is interesting. Maybe I could update my question to enlarge it to `char`? I do not know if this is a "good practice" on SO. – Boiethios Jun 19 '17 at 08:22
-
All answers deal with `int` so changing your question to include `char` will make the answers look incomplete. I would not update the question. Just my opinion. I could be wrong. – bolov Jun 19 '17 at 08:25
-
2Nah, There's already a question for that: [Is char signed or unsigned by default?](https://stackoverflow.com/q/2054939/3049655) – Spikatrix Jun 19 '17 at 08:26
3 Answers
You are quite right. As per C11
(the latest c standard), chapter §6.7.2
int
,signed
, orsigned int
is categorized as same type (type specifiers, to be exact). So, int
is the same as signed int
.
Also, re-iterating the same, from chapter §6.2.5/P4
There are five standard signed integer types, designated as
signed char
,short int
,int
,long int
, andlong long int
. (These and other types may be designated in several additional ways, as described in 6.7.2.) [....]
So, for any conforming environment, int
stands for signed int
and vice versa.

- 133,132
- 16
- 183
- 261
-
1
-
@Boiethios I'm not sure about `C89/90`, but it's all the same from `C99` and I see no reason for it to be otherwise for earlier days either. – Sourav Ghosh Jun 19 '17 at 09:31
-
1In C89, under `§3.5.2 Type specifiers` it states `int , signed , signed int , or no type specifiers (...) the above comma-separated lists designates the same type, except that for bit-field declarations, signed int (or signed ) may differ from int (or no type specifiers).` – Tardis Jun 19 '17 at 10:37
-
@Tardis Awesome...that's it. Thanks for the info, let me add it to my answer. – Sourav Ghosh Jun 19 '17 at 10:38
-
Sure, add it :-) It should answer @Boiethios 's additional question. It is worth noting, as the quoted language from §3.5.2 suggests, that also another synonymous of `int` according to C89 was "no type specifier", since in such a case `int` was implied, and that this implicit typing was removed from the the C standard starting from C99. There is a [post](https://stackoverflow.com/questions/26189962/implicit-int-in-c-language#26190042) on SO about this. – Tardis Jun 19 '17 at 11:11
-
Tardis, sure C99 foreward mentions about removing implicit ints, both as a type specifier and function declarations, too. – Sourav Ghosh Jun 19 '17 at 11:12
int
, signed
, and signed int
are all the same type.
The exact form of int
is implementation specific; the range must be at least -32767 to +32767. There is no upper limit on the range. Note also that the complement scheme can differ too: 2's complement is common these days although 1's complement and signed magnitude are also allowed.

- 231,907
- 34
- 361
- 483
According to this Wikipedia article, int
is a signed integral data type which is at least 16 bits in size.

- 17,447
- 9
- 29
- 56
-
5100% correct, but it is always good to use primary authority like the standard. (just a nit, but a formally important one `:)` – David C. Rankin Jun 19 '17 at 07:47
-