In some cases we use long long in C or C++. Here we will see what is long long basically? long long takes up twice as much memory space as long. In different systems, the allocated memory space is different. In the Linux environment, long occupies 64 bits (8 bytes) of space, while long long occupies 128 bits (16 bytes) of space. This can be used when we want to handle some large integer values.
We can use this simple program to test different types of sizes.
#include <iostream> using namespace std; main() { int a; long b; long long c; cout << "Size of int = "<< sizeof(a) <<" bytes \n"; cout << "Size of long = "<< sizeof(b) <<" bytes\n"; cout << "Size of long long = "<< sizeof(c) <<" bytes\n"; }
Size of int = 4 bytes Size of long = 4 bytes Size of long long = 8 bytes
The output may vary on different systems. The windows platform is used here for testing.
The above is the detailed content of In C/C++, long long is a data type used to represent a larger range of integers. It usually occupies 8 bytes of storage space and can represent a larger range of integers than the ordinary long type.. For more information, please follow other related articles on the PHP Chinese website!