You are here:About>Computing & Technology>C / C++ / C#> C> C Tutorials> More About Ints
About.comC / C++ / C#

C Tutorial Lesson Two - Handling Numbers

From David Bolton,
Your Guide to C / C++ / C#.
FREE Newsletter. Sign Up Now!

More About Ints

What is the biggest number an int can store?. Well it depends on the type of CPU but for the next few years it will most likely remain as 32 bits. Because it can hold almost as many negative values as positive, the range of values is +/- 2-32 to 232 or -2,147,483,648 to +2,147,483,647.

This is for a signed int, but there is also an unsigned int that holds zero or positive. It has a range of 0 to 4,294,967,295. Just remember- unsigned ints don't need a sign (like + or -1) in front of them because they are always + (or 0).

There is a longer 64 bit int type called long long and some compilers use an alternate name- eg both Borland and Microsoft uses _int64. This has a range of -9223372036854775807 to 9223372036854775807 (signed) and 0 to 18446744073709551615 (unsigned).

Short Ints

There is a shorter int type, coincidentally called short int which use 16 bits (2 bytes). This holds numbers in the range -32768 to +32767. If you usea large umber of ints, you can possibly save memory by using short ints. It will not be any quicker, despite being half the size. 32 Bit CPUs fetch values from memory in blocks of 4 bytes at a time. Ie 32 bits (Hence the name- 32 Bit CPU!). So fetching 16 bits still requires a 32 bit fetch.

As with ints there is an unsigned short int type that has a range of 0..65535.

Note : Some computer languages refer to 16 bits as a Word

On the next page : Learn about precision in floats.

  1. All About Numbers in C
  2. More About Ints
  3. Precision Arithmetic
  4. Learn about Arithmetic Operations
  5. Specifying Output Formats in Printf
  6. Learn how to use Format Specifiers

<< Previous | Next >>

 All Topics | Email Article | Print this Page | |
Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.