You are here

General Discussion

5 February, 2015 - 15:41

The integer data type has two meanings:

  • The integer data type with its various modifers that create different domains
  • The integer family which also includes the Boolean and character data types

The integer data type basically represents whole numbers (no fractional parts). The integer values jump from one value to another. There is nothing between 6 and 7. It could be asked why not make all your numbers floating point which allow for fractional parts. The reason is twofold. First, some things in the real world are not fractional. A dog, even with only 3 legs, is still one (1) dog not i of a dog. Second, integer data type is often used to control program fow by counting, thus the need for a data type that jumps from one value to another.

The integer data type has the same attributes and acts or behaves similarly in all programming languages. The most often used integer data type in C++ is the simple integer.

C++ Reserved Word



Whole numbers (no fractional parts)


Usually 4 bytes

Normal Signage

Signed (negative and positive values)

Domain (Values Allowed)

-2,147,483,648 to 2, 147,483,647

C++ syntax rule

Do not start with a 0 (zero)

C++ syntax rule

No decimal point

Within C++ there are various reserved words that can be used to modify the size or signage of an integer. They include: long, short, signed and unsigned. Signed is rarely used because integers are signed by default you must specify unsigned if you want integers that are only positive. Possible combinations are:

C++ Reserved Word Combination


short int


unsigned short int




unsigned int


long int


unsigned long int


The domain of each of the above data type options varies with the complier being used and the computer. The domains vary because the byte size allocated to the data varies with the compiler and computer. This effect is known as being machine dependent. Additionally, there have been some size changes with upgrades to the language. In "C" the int data type was allocated 2 bytes of memory storage on an Intel compatible central processing unit (cpu) machine. In "C++" an int is allocated 4 bytes.

These variations of the integer data type are an annoyance in C++ for a beginning programmer. For a beginning programmer it is more important to understand the general attributes of the integer data type that apply to most programming languages.