2

If there is some positive integer literal in my code, say 50, does the compiler consider it as type unsigned int or int?

mah
  • 39,056
  • 9
  • 76
  • 93
user2460978
  • 735
  • 6
  • 19

1 Answers1

6

A decimal integer literal is of the first type where it can be represented in int, long or long long.

50 is of type int.

unsigned literals can be specified using the u or U suffix. A decimal integer literal suffixed with u or U is of the first type where it can be represented in unsigned int, unsigned long or unsigned long long.

50U is of type unsigned int.

ouah
  • 142,963
  • 15
  • 272
  • 331