Can unsigned long int hold a ten digits number (1,000,000,000 – 9,999,999,999) on a 32-bit computer?
Additionally, what are the ranges of unsigned long int , long int, unsigned int, short int, short unsigned int, and int?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The minimum ranges you can rely on are:
short intandint: -32,767 to 32,767unsigned short intandunsigned int: 0 to 65,535long int: -2,147,483,647 to 2,147,483,647unsigned long int: 0 to 4,294,967,295This means that no,
long intcannot be relied upon to store any 10-digit number. However, a larger type,long long int, was introduced to C in C99 and C++ in C++11 (this type is also often supported as an extension by compilers built for older standards that did not include it). The minimum range for this type, if your compiler supports it, is:long long int: -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807unsigned long long int: 0 to 18,446,744,073,709,551,615So that type will be big enough (again, if you have it available).
A note for those who believe I’ve made a mistake with these lower bounds: the C requirements for the ranges are written to allow for ones’ complement or sign-magnitude integer representations, where the lowest representable value and the highest representable value differ only in sign. It is also allowed to have a two’s complement representation where the value with sign bit 1 and all value bits 0 is a trap representation rather than a legal value. In other words,
intis not required to be able to represent the value -32,768.