1. Home
  2. Computing & Technology
  3. C / C++ / C#

C++ Tutorial - Lesson One Learning How to Compile With Visual C++ 2005

By David Bolton, About.com

5 of 8

Learn 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).

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.

Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. C++
  5. Learn C++ Programming
  6. More About Ints

©2009 About.com, a part of The New York Times Company.

All rights reserved.