Is `int` signed?

I always thought that in C, intmeans signed int; but I heard that this behavior is platform-specific, and on some platforms int, unsignedthe default. It's true? What does the standard say and has it evolved over time?

+4
source share
3 answers

You are absolutely right. According to C11(last c standard), chapter §6.7.2

  • int, signedorsigned int

is classified as the same type (for example, type specifiers). So, intcoincides with signed int.

In addition, the repetition of the same, from the chapter §6.2.5 / P4

, signed char, short int, int, long int long long int. ( , 6.7.2.) [....]

, int signed int .

+12

int, signed signed int - .

int ; -32767 +32767. . , : 2 , 1 .

+6

In accordance with this , the Wikipedia article intis a signed integer data type with a size of at least 16 bits.

+2
source

Source: https://habr.com/ru/post/1679597/


All Articles