# why omit unsigned int in unsuffixed decimal integer constant?

This is a discussion on why omit unsigned int in unsuffixed decimal integer constant? within the C Programming forums, part of the General Programming Boards category; Hi, In the K&R C II, Code: The type of an integer constant depends on its form, value and suffix. ...

1. ## why omit unsigned int in unsuffixed decimal integer constant?

Hi,

In the K&R C II,
Code:
The type of an integer constant depends on its form, value and suffix.
(See Par.A.4 for a discussion of types). If it is unsuffixed and decimal, it
has the first of these types in which its value can be represented: int,
long int, unsigned long int. If it is unsuffixed, octal or hexadecimal, it
has the first possible of these types: int, unsigned int, long int,
unsigned long int. If it is suffixed by u or U, then unsigned int, unsigned
long int. If it is suffixed by l or L, then long int, unsigned long int. If an
integer constant is suffixed by UL, it is unsigned long.
compared to int, unsigned int can represent bigger positive numbers, just like unsigned long vs. long. If int is assigned to 8 bits, then its range for positive number is [0, +127], while unsigned int is [0, +255]. An integer constant like 200 can be represented as unsigned int, which doesn't have to be long (which maybe has bigger bits than int).
Just like unsuffixed octal and hex integer constants, they take an order int->unsigned int->long->unsigned log. I think this is more reasonable, don't understand why unsuffixed decimal integer skip unsigned int. Could anyone please explain it to me?

THANKS!!

2. An integer constant (unsuffixed decimal digits) is placed in a signed integral type, never in an unsigned one. The order in the 1999 C standard is int, long, long long NOT int, long, unsigned long,

3. Originally Posted by grumpy
An integer constant (unsuffixed decimal digits) is placed in a signed integral type, never in an unsigned one. The order in the 1999 C standard is int, long, long long NOT int, long, unsigned long,
I'm talking about C90 actually, and it does take the order int, long, unsigned long. Why never in an unsigned one? What about unsuffixed octal and hex integer constant? They can also be unsigned.

4. It could well be a matter of common usage: the decimal representation tends to see use with signed integer variables, so the type of the literal without suffix is only made unsigned when necessary, and then made only signed in C99. The octal and hexadecimal representations tend to see use with unsigned integer variables as they may be involved in bitwise operations, so prefering the unsigned version of an integer conversion rank to the signed version of the next rank makes sense.