C++C++11C++14C++17C++20Introduction to C++Learn C++

What Is The Long Long Int Type In C++?

What Is The Long Long Int Type In C++

In the early days of C++ there were few data types such as char, float, and int. Over time these types improved with new additions. Modern C++ is really amazing, it allows you to define your data type in accordance with the limits of your variable values. One of the largest integer types is the unsigned long long or unsigned long long int and in this post we explain how to use the long long int type.

What are the fundamental variables In C++?

A professional developer should always know the size of data types and their limits and which data types of a variable is needed in these limits, because the operating system allocates memory and decides what can be stored in the reserved memory.

In addition to standard types in C++, there are fixed-width integers which are defined types in header <cstdint> with a fixed number of bits. Fixed-width integers are called as intN_t or intX_t integers where N or X represents number of bits reserved for that type. 

What is long long int type in C++?

The long long integral type (or long long int) is an integer type for the larger numbers that doubles bytes of long type integer. The long long and long long int types are identical as same as long and long int types are identical. In modern C++, C++11 standard introduced long long integral type to be more compatible with C99 standards. Detailed information on this feature, can be seen in this proposal: long long type Proposal document.

Adding long long was proposed previously by Roland Hartinger in June of 1995. At the time, long long had not been considered by the C committee, and the C++ committee was reluctant to add a fundamental type that was not also in C. Almost a decade later long long was part of C99, and many major C++ compilers start to support it. long long has been added to standards with C++11.

If we consider that int variable has size of 4 bytes, long long int has size of 8 bytes. usigned long long int is same.

Here are the most used integer types in C++,

TypeTypical Bit WidthTypical Range
int4bytes-2147483648 to 2147483647
unsigned int4bytes0 to 4294967295
signed int4bytes-2147483648 to 2147483647
short int2bytes-32768 to 32767
unsigned short int2bytes0 to 65,535
signed short int2bytes-32768 to 32767
long int4bytes-2,147,483,648 to 2,147,483,647
signed long int4bytessame as long int
unsigned long int4bytes0 to 4,294,967,295
long long int8bytes-(2^63) to (2^63)-1
unsigned long long int8bytes0 to 18,446,744,073,709,551,615

Is there a simple example of how to use the long long int type in C++?

Here is a simple example that shows how you can use int, long int long long int, unsigned long long int,

Is there an example of how to use long long int type in C++?

Here is an example of how you can use long long, long long int and unsigned long long, unsigned long long int,

here is the output,

Are there larger int types than the long long int type in C++?

One of the most common scientific problems in programming is the limitation of numbers that we use. If you are about to calculate very large numbers (i.e. factorial 100!) there are the Boost C++ Libraries which is a set of C++ libraries that you can use to help with computational operations. Do you know that you can use very large numbers with Boost libraries with almost any modern C++ compiler? Here is how you can use very large integer numbers,

What Is The Long Long Int Type In C++ C++ Builder logo

C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, MacOS, iOS & Android operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise version.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?