9.2 Integer Data Types
The following table shows integer data types that are supported in the compiler. All unspecified or signed integer data types are arithmetic type signed integer. All unsigned integer data types are arithmetic type unsigned integer.
Type | Bits | Min. | Max. |
---|---|---|---|
char, signed char |
8 | -128 | 127 |
unsigned char |
8 | 0 | 255 |
short, signed short |
16 | -32768 | 32767 |
unsigned short |
16 | 0 | 65535 |
int, signed int |
32 | -231 | 231 - 1 |
unsigned int |
32 | 0 | 232 - 1 |
long, signed long |
32 | -231 | 231 - 1 |
unsigned long |
32 | 0 | 232 - 1 |
long long, signed long long |
64 | -263 | 263 - 1 |
unsigned long long |
64 | 0 | 264 - 1 |
Type | Bits | Min. | Max. |
---|---|---|---|
char, signed char |
8 | -128 | 127 |
unsigned char |
8 | 0 | 255 |
short, signed short |
16 | -32768 | 32767 |
unsigned short |
16 | 0 | 65535 |
int, signed int |
16 | -32768 | 32767 |
unsigned int |
16 | 0 | 65535 |
long, signed long |
32 | -231 | 231 - 1 |
unsigned long |
32 | 0 | 232 - 1 |
long long, signed long
long |
64 | -263 | 263 - 1 |
unsigned long long |
64 | 0 | 264 - 1 |
There is no type for storing single bit quantities.
All integer values are specified in little endian format, which means:
- The least significant byte (LSB) is stored at the lowest address
- The least significant bit (LSb) is stored at the lowest-numbered bit position
As an example, the long value of 0x12345678
is stored at
address 0x100
as follows:
0x100 |
0x101 |
0x102 |
0X103 |
---|---|---|---|
0x78 |
0x56 |
0x34 |
0x12 |
As another example, for dsPIC33C/E/F and dsPIC30F devices the long value
of 0x12345678
is stored in registers w4 and w5:
w4 | w5 |
---|---|
0x5678 |
0x1234 |
Signed values are stored as a two’s complement integer value.
Preprocessor macros that specify integer minimum and maximum values are
available after including <limits.h>
in your source code, located by
default in:
<install directory>\include
As the size of data types is not fully specified by the ANSI Standard, these macros allow for more portable code which can check the limits of the range of values held by the type on this implementation.
For information on implementation-defined behavior of integers, see 22.5 Integers.