Samstag, 15. Oktober 2011

EE4209/EE5809 Digital Audio : C Primitive Data types

EE4209/EE5809 Digital Audio : C Primitive Data types

source :

The GNU C Reference Manual
http://www.gnu.org/s/gnu-c-manual/gnu-c-manual.html#Data-Types

2.1 Primitive Data Types

Integer Types
Real Number Types
Complex Number Types

Next: Real Number Types, Up: Primitive Types
2.1.1 Integer Types

The integer data types range in size from at least 8 bits to at least 32 bits. The C99 standard extends this range to include integer sizes of at least 64 bits.


You should use integer types for storing whole number values ( and the char data type for storing characters). ( Note that the sizes and ranges listed for these types are minimums; depending on your computer platform, these sizes and ranges may be larger.)

While the minimum ranges provide a natural ordering, the standard does not require that any two types have a different range.

For example, it is common for int and long to have the same range. The standard even allows signed char and long to have the same range, though such platforms are very unusual.

- signed char
The 8-bit signed char data type can hold integer values in the range of −128 to 127.

- unsigned char
The 8-bit unsigned char data type can hold integer values in the range of 0 to 255.

- char
Depending on your system, the char data type is defined as having the same range as either the signed char or the unsigned char data type (they are three distinct types, however).

By convention, you should use the char data type specifically for storing ASCII characters (such as `m'), including escape sequences (such as `\n').


- short int :
The 16-bit short int data type can hold integer values in the range of −32,768 to 32,767. You may also refer to this data type as short, signed short int, or signed short.

- unsigned short int :
The 16-bit unsigned short int data type can hold integer values in the range of 0 to 65,535. You may also refer to this data type as unsigned short.

- int :
The 32-bit int data type can hold integer values in the range of −2,147,483,648 to 2,147,483,647. You may also refer to this data type as signed int or signed.

- unsigned int :
The 32-bit unsigned int data type can hold integer values in the range of 0 to 4,294,967,295. You may also refer to this data type simply as unsigned.


- long int :
The 32-bit long int data type can hold integer values in the range of at least −2,147,483,648 to 2,147,483,647.
( Depending on your system, this data type might be 64-bit, in which case its range is identical to that of the long long int data type.) You may also refer to this data type as long, signed long int, or signed long.


- unsigned long int :
The 32-bit unsigned long int data type can hold integer values in the range of at least 0 to 4,294,967,295.
( Depending on your system, this data type might be 64-bit, in which case its range is identical to that of the unsigned long long int data type.) You may also refer to this data type as unsigned long.

- long long int :
The 64-bit long long int data type can hold integer values in the range of −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
You may also refer to this data type as long long, signed long long int or signed long long. This type is not part of C89, but is both part of C99 and a GNU C extension.


- unsigned long long int :
The 64-bit unsigned long long int data type can hold integer values in the range of at least 0 to 18,446,744,073,709,551,615.
You may also refer to this data type as unsigned long long. This type is not part of C89, but is both part of C99 and a GNU C extension.

--- -

Here are some examples of declaring and defining integer variables:

int foo;
unsigned int bar = 42;
char quux = 'a';

The first line declares an integer named foo but does not define its value; it is left unintialized, and its value should not be assumed to be anything in particular.



Keine Kommentare: