Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number suffix for short [duplicate]

Tags:

c++

c

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?

like image 492
André Puel Avatar asked Jan 31 '12 18:01

André Puel


People also ask

What is the suffix of short?

so no, there is no suffix for shorts.

How do you write short in C++?

For example, // small integer short a = 12345; Here, a is a short integer variable. Note: short is equivalent to short int .

What is UL in C++?

Unsigned constants are written with a terminal u or U , and the suffix ul or UL indicates unsigned long . Floating-point constants contain a decimal point ( 123.4 ) or an exponent ( 1e-2 ) or both; their type is double , unless suffixed.


2 Answers

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.

like image 177
Joachim Isaksson Avatar answered Oct 21 '22 03:10

Joachim Isaksson


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.

like image 31
ouah Avatar answered Oct 21 '22 03:10

ouah