Integer Variables

Integer variables fall into the following categories:

Note:
C++ The integer types long long int and unsigned long long int are orthogonal extensions to Standard C++.

The default integer type for a bit field is unsigned.

The amount of storage allocated for integer data is implementation-dependent.

The unsigned prefix indicates that the object is a nonnegative integer. Each unsigned type provides the same size storage as its signed equivalent. For example, int reserves the same storage as unsigned int. Because a signed type reserves a sign bit, an unsigned type can hold a larger positive integer value than the equivalent signed type.

The declarator for a simple integer definition or declaration is an identifier. You can initialize a simple integer definition with an integer constant or with an expression that evaluates to a value that can be assigned to an integer. The storage class of a variable determines how you can initialize the variable.

C++ When the arguments in overloaded functions and overloaded operators are integer types, two integer types that both come from the same group are not treated as distinct types. For example, you cannot overload an int argument against a signed int argument.

Examples of Integer Data Types

The following example defines the short int variable flag:

short int flag;

The following example defines the int variable result:

int result;

The following example defines the unsigned long int variable ss_number as having the initial value 438888834 :

unsigned long ss_number = 438888834ul;

Related References

IBM Copyright 2003