Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Literal types: 0x1ull vs 0x1llu

Tags:

c

literals

My gcc compiler allows me to define an unsigned long long (i.e. 64-bit) literal as

#define A_LITERAL 0x1ull

--- or ---

#define A_LITERAL 0x1llu

Is there any difference between these two literal statements. Is this common to other C compilers?

like image 958
Benjamin Leinweber Avatar asked Jun 25 '13 01:06

Benjamin Leinweber


2 Answers

Both are the same: excerpt from n3337 draft of C++11 standard:

integer-suffix:
    unsigned-suffix long-suffix(opt)
    unsigned-suffix long-long-suffix(opt)
    long-suffix unsigned-suffix(opt)
    long-long-suffix unsigned-suffix(opt)

unsigned-suffix: one of
    u U

long-suffix: one of
    l L

long-long-suffix: one of
    ll LL
like image 115
Mats Petersson Avatar answered Oct 06 '22 04:10

Mats Petersson


Both are allowed by the C standard (section 6.4.4.1).

The unsigned suffix u can be before or after the long l (or long long (ll)) suffix.

like image 26
Some programmer dude Avatar answered Oct 06 '22 04:10

Some programmer dude