Home > Backend Development > C++ > body text

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
Release: 2023-09-09 21:05:02
forward
1690 people have browsed it

在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";
}
Copy after login

Output

Size of int = 4 bytes
Size of long = 4 bytes
Size of long long = 8 bytes
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!