Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "long long" = "long long int" = "long int long" = "int long long"?

People also ask

How long is long long int?

In different systems, the allocated memory space differs. On Linux environment the long takes 64-bit (8-bytes) of space, and the long long takes 128-bits (16-bytes) of space. This is used when we want to deal with some large value of integers. We can test the size of different types using this simple program.

What is long long int in Java?

The Java long keyword is a primitive data type. It is used to declare variables. It can also be used with methods. It can hold a 64-bit two's complement integer.

What does long int mean?

A long integer is a data type in computer science whose range is greater (sometimes even double) than that of the standard data type integer. Depending on the programming language and the computer machine processor, the size of the long integer will vary.


According to the C++ Standard (7.1.6.2 Simple type specifiers)

3 When multiple simple-type-specifiers are allowed, they can be freely intermixed with other decl-specifiers in any order.

So for example the following declaration is valid

long static long const int x = 10;

You may even use constexpr specifier along with const qualifier. For example

constexpr long static long const int x = 10;

By the way, we forgot about specifier signed! Let's add it for example before declarator x

constexpr long static long const int signed x = 10;

In C you may also use several type qualifiers in the same declare specifier sequence. According to the C Standard (6.7.3 Type qualifiers)

5 If the same qualifier appears more than once in the same specifier-qualifier-list, either directly or via one or more typedefs, the behavior is the same as if it appeared only once....

So for example in C the following declaration is also valid

const long const long static const int const signed x = 10;

So if you are paid according to the number of symbols typed in the program then I advise you to use such declarations. :)


Is the type identical...

Yes.

C++11 §7.1.6.2/3

When multiple simple-type-specifiers are allowed, they can be freely intermixed with other decl-specifiers in any order.


Yes, but please don't. Just as English and German have conventional word orders for adjectives and adverbs (e.g. time - manner - place), so do C and C++. Varying from the conventional order won't confuse the compiler, but it will confuse your fellow developers. I would suggest that the conventional order is roughly along the lines of

  1. static/extern (linkage)
  2. const/volatile (modification)
  3. signed/unsigned (signedness)
  4. short/long (length)
  5. Basic type (head noun)

although there's certainly some wiggle room.


Is “long long” = “long long int” = “long int long” = “int long long”?

All other answers here talked about the second part of your question. For the first part: Is “long long” = “long long int” ?, answer is yes.

C++11 7.1.6.2 Simple type specifiers (table 10)

Specifier(s)            Type
...                     ...
long long int           “long long int”
long long               “long long int”
long int                “long int”
long                    “long int”  
...                     ...  

For the second part of your question: Is “long int long” = “int long long”?, answer is yes again.

The type-specifiers may occur in any order and can be intermixed with the other declaration specifiers. Therefore, all of the following

long long  
long long int  
long int long  
int long long  

are valid and equivalent.