What range of values can integer types store in C

0 votes
On a 32-bit machine, can an unsigned long int carry a ten-digit value (1,000,000,000 - 9,999,999,999)?

What are the unsigned long int, long int, unsigned int, short int, short unsigned int, and int ranges?
Jun 21 in C++ by Nicholas
• 5,940 points
38 views

1 answer to this question.

0 votes
You may rely on the following minimal ranges:

-32,767 to 32,767 unsigned short int and int: 0 to 65,535 long int: 0 to 65,535

unsigned long int: 0 to 4,294,967,295 -2,147,483,647 to 2,147,483,647

This means that long int cannot be used to hold any ten-digit value.

However, in C99 and C++11, a bigger type long long int was added (this type is also often supported as an extension by compilers built for older standards that did not include it).

If your compiler supports it, the minimal range for this type is:

long long int: -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807 unsigned long long int: 0 to 18,446,744,073,709,551,615 long long int: 0 to 18,446,744,073,709,551,615

So that kind will suffice (again, assuming you have it).
answered Jun 21 by Damon
• 4,960 points

Related Questions In C++

0 votes
0 answers

What type of members can I add in a c++ abstract class

Hello, let's say I have an abstract class with a few pure abstract functions and a few classes that derive from it, and all of the data from these classes eventually becomes similar, I was wondering if it would be wise, or even possible, to declare a vector under protected in the abstract class to collect the data so something like that. class A { protected: vector <string> ...READ MORE

Jul 27 in C++ by Nicholas
• 5,940 points
28 views
0 votes
0 answers

What is the meaning of "generic programming" in c++?

What does generic programming in C++ mean? I'm ...READ MORE

Jul 11 in C++ by Nicholas
• 5,940 points
44 views
0 votes
0 answers

What is the difference between cout, cerr, clog of iostream header in c++? When to use which one?

I looked up the differences between cout, ...READ MORE

Jul 27 in C++ by Nicholas
• 5,940 points
28 views
0 votes
1 answer

Cases of static and dynamic binding in C++

When an object's static type is used to associate it with a member function, this is known as static binding (understand the type of its class). When a pointer or reference is associated with a member function based on the dynamic type of the object, this is known as dynamic binding (understand the instance of the variable at runtime). Before continuing, keep in mind that dynamic binding only works with pointers, references, and virtual functions for the base class. Because everything needed to call the function is known at compile time, the first call is a static binding (also known as early binding). Derived1 d1(1, 10); d1.display_data(); You already know that the d1 instance is a Derived1 automatic variable, and that it will call the Derived1::display data method (). The first condition is incorrect: d1 is neither a pointer nor a reference. The second condition isn't acceptable:  There is no virtual Derived1::display data. The second call is for ...READ MORE

answered Jun 7 in C++ by Damon
• 4,960 points
31 views
0 votes
1 answer

Easiest way to convert int to string in C++

The C++11 version has introduced the std::stoi ...READ MORE

answered Feb 10 in Others by Rahul
• 9,240 points
49 views
0 votes
1 answer

Easiest way to convert int to string in C++

C++ adds std::stoi (and variants for each numeric type) and std::to string, which are the C equivalents of atoi and itoa but expressed in terms of std::string #include <string> std::string s = std::to_string(42); Is therefore ...READ MORE

answered Jun 1 in C++ by Damon
• 4,960 points
162 views
0 votes
1 answer

casting int to char using C++ style casting [duplicate]

Even though the precision is lost, yo ...READ MORE

answered Jun 13 in C++ by Damon
• 4,960 points
150 views
0 votes
1 answer

Easiest way to convert int to string in C++

std::stoi (and variations for each numeric type) ...READ MORE

answered Jun 15 in C++ by Damon
• 4,960 points
83 views
0 votes
1 answer

What is dynamic initialization of object in c++?

Dynamic initialization occurs when the initialization value is unknown at compile time.  To initialise the variable, it is calculated at runtime. Example, int factorial(int n) { ...READ MORE

answered Aug 2 in C++ by Damon
• 4,960 points
35 views
0 votes
1 answer

What data structure is inside std::map in C++?

An associative container is std::map. The standard's ...READ MORE

answered May 31 in C++ by Damon
• 4,960 points
59 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP