In Mathematics, there is no limitation on number. But, in computer world, everything are in binary format, and there are limited amount of memory.

Different data are represented in different ways in computer memory, and have different value ranges.

Primitive data types

The C language represents numbers in three forms: integralreal and complex. This distinction reflects similar distinctions in the instruction set architecture of most central processing unitsIntegral data types store numbers in the set of integers, while real and complex numbers represent numbers (or pair of numbers) in the set of real numbers in floating point form.

Integer types

C's integer types come in different fixed sizes, capable of representing various ranges of numbers.

Shortest form of specifierMinimum width (bits)
_Bool 1
char 8
signed char 8
unsigned char 8
short 16
unsigned short 16
int 16
unsigned int 16
long 32
unsigned long 32
long long 64
unsigned long long 64

Floating point types

The floating-point form is used to represent numbers with a fractional component. They do not, however, represent most rational numbers exactly; they are instead a close approximation. There are three types of real values, denoted by their specifiers: single precision (float), double precision (double), and double extended precision (long double). Each of these may represent values in a different form, often one of the IEEE floating-point formats.

Type specifiersPrecision (decimal digits)Exponent range
MinimumIEEE 754MinimumIEEE 754
float 6 7.2 (24 bits) ±37 ±38 (8 bits)
double 10 15.9 (53 bits) ±37 ±307 (11 bits)
long double 10 34.0 (113 bits) ±37 ±4931 (15 bits)

Storage class specifiers

Every object has a storage class. This specifies most basically the storage duration, which may be static (default for global), automatic (default for local), or dynamic (allocated), together with other features (linkage and register hint).

SpecifiersLifetimeScopeDefault initializer
auto Block (stack) Block Uninitialized
register Block (stack or CPU register) Block Uninitialized
static Program Block or compilation unit Zero
extern Program Block or compilation unit Zero
(none) Dynamic (heap)   Uninitialized

Type qualifiers

Types can be qualified to indicate special properties of their data. The type qualifier const indicates that a value does not change once it has been initialized. Attempting to modify a const qualified value yields undefined behavior, so some C compilers store them in rodata or (for embedded systems) in read-only memory (ROM).

You have no rights to post comments