"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > What is the Maximum Value Representable by an Unsigned Long Int in C++?

What is the Maximum Value Representable by an Unsigned Long Int in C++?

Published on 2024-11-01
Browse:192

What is the Maximum Value Representable by an Unsigned Long Int in C  ?

Integer Value Ranges in C : Capacity and Compatibility

While working with integer types in C , it's crucial to understand the range of values they can store. This knowledge helps ensure that you select the appropriate type for your specific requirements.

The minimum ranges guaranteed by the C standard for common integer types are as follows:

  • short int and int: -32,767 to 32,767
  • unsigned short int and unsigned int: 0 to 65,535
  • long int: -2,147,483,647 to 2,147,483,647
  • unsigned long int: 0 to 4,294,967,295

These ranges indicate that unsigned long int cannot reliably store a ten-digit number (1,000,000,000 - 9,999,999,999) on a 32-bit computer as it exceeds the maximum representable value of 4,294,967,295.

However, a larger type, long long int, was introduced in C99 and C 11 to handle wider integer values. The minimum range for long long int 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

This extended range allows long long int to comfortably accommodate ten-digit numbers. Note that the availability of long long int is compiler-specific, so it's essential to check its support in your environment.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3