Home  >  Article  >  Backend Development  >  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 ?

Susan Sarandon
Susan SarandonOriginal
2024-10-30 00:03:03530browse

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.

The above is the detailed content of What is the Maximum Value Representable by an Unsigned Long Int in C ?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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