Home >Backend Development >C++ >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.

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.

WBOY
WBOYforward
2023-09-09 21:05:021743browse

在C/C++中,long long是一种数据类型,用于表示更大范围的整数。它通常占据8个字节的存储空间,并可以表示的整数范围更大,比普通的long类型更长

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.

Example

#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";
}

Output

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete