Home > Backend Development > C++ > body text

Can unsigned long int Reliably Store a Ten-Digit Number in C ?

Barbara Streisand
Release: 2024-10-31 18:43:02
Original
956 people have browsed it

Can unsigned long int Reliably Store a Ten-Digit Number in C  ?

Integers' Value Ranges in C

In C , the range of values that integer types can store depends on their size and whether they are signed or unsigned. For a 32-bit computer, the minimum ranges guaranteed by the C standard are:

  • 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

Given these ranges, unsigned long int cannot reliably hold a ten-digit number (1,000,000,000 - 9,999,999,999) on a 32-bit computer.

However, for larger numbers, C99 and C 11 introduced the long long int type, which offers a wider range:

  • 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

With these expanded ranges, unsigned long long int provides ample capacity to store a ten-digit number. It should be noted that long long int is not always supported by older compilers, so its availability should be verified before relying on it.

The above is the detailed content of Can unsigned long int Reliably Store a Ten-Digit Number in C ?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!