18

Possible Duplicate:
How do I write a short literal in C++?

I can use ll to represent a long long number, I can use u to represent a unsigned number, etc.

Is there a number suffix for short type?

Community
  • 1
  • 1
André Puel
  • 8,741
  • 9
  • 52
  • 83

2 Answers2

19

The C++ standard only gives these integer suffixes (2.13.1)

unsigned-suffix: one of
u U
long-suffix: one of
l L
long-long-suffix: one of
ll LL

so no, there is no suffix for shorts.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • According to the C++ standard http://en.cppreference.com/w/cpp/language/integer_literal, since C++11, l or L is a suffix for "long long int". – Alex Sed Dec 01 '17 at 02:16
5

No there is no integer constant suffix for short in C.

In most expressions a short value is promoted to int so it is not so useful. You can cast an int integer constant to short, but with the integer promotions rules, chances are it will be promoted to int.

ouah
  • 142,963
  • 15
  • 272
  • 331