189k views
1 vote
Assume that you need a variable named big to represent an integer greater than 2,147,483,647 (i.e. > 232-1-1). What type would you declare big?

1 Answer

6 votes

Final answer:

To represent an integer greater than 2,147,483,647, a 'long' data type should be used in Java, and a 'long long' or 'long' (depending on compiler and platform) should be used in C++ as they offer 64-bit storage.

Step-by-step explanation:

To represent a whole number larger than 2,147,483,647, which is the maximum value for a 32-bit signed integer, you would need to declare a variable of a type that can hold larger values. In most programming languages, such a type that can store larger integer values is known as a long or long long integer, which is typically a 64-bit integer. For Java, you would use the long data type, and in C/C++, you could use either long long or long depending on the compiler and the platform.

For example, in Java, you would declare the variable big as follows:

long big;

In C++, the declaration might look like this:

long long big;

These types can hold values much larger than 2,147,483,647, specifically up to 9,223,372,036,854,775,807 for long in Java or for long long in C++.

User Merilyn
by
7.3k points