C++ `long long` variable type

2.7k Views Asked by At

I am now studying about writing binary files. I've seen this question on StackOverflow. And the author says, in his code

const unsigned long long size = 1ULL*1024ULL*1024ULL;

I don't actually know what are the ULL symbols. Could anybody give me some documentation about it? I have searched on Google, and everything I get is more documentation about writing files...

2

There are 2 best solutions below

3
On BEST ANSWER

It is a suffix that specifies the type of literal (in this case, integer literals).

You can find out more about this in the C++ standard, specifically in 2.14 - Literals

In your case, the answer lies in the following table (from this very part of the standard) : unsigned long long.

Integer literals suffixes

0
On

It makes 1 and 1024 be unsigned long long constants or else they'd default to int (in terms of how many bytes the value will take to be represented):

std::cout << sizeof(1ULL) << sizeof(1);