Search code examples
c++intunsignedsigned

Is int implicitly signed (C++)?


In C++, when I say int i = 0;

is the int now automatically signed int i = 0; or unsigned int i = 0;?

I haven't found an answer through Google


Solution

  • The C++11 standard (draft) §3.9.1.2 has this to say;

    There are five standard signed integer types : “signed char”, “short int”, “int”, “long int”, and “long long int”.

    The C11 standard (draft) §6.2.5.4 has this to say;

    There are five standard signed integer types, designated as signed char, short int, int, long int, and long long int

    It would seem they're both in agreement that int is a signed type.

    (C89 §3.1.2.5 also agrees, so it would seem to have been that way as far as I can go back)