5.3.2 Integer Data Types

The MPLAB XC8 compiler supports integer data types with widths of 1, 2, 3, 4, and 8 bytes. Additionally, it supports a single bit type. The table below shows the data types and their corresponding size and arithmetic type. The default type for each type group is in bold.

Table 5-1. Integer Data Types
TypeSize (bits)Arithmetic Type
__bit1Unsigned integer
signed char8Signed integer
unsigned char8Unsigned integer
signed short16Signed integer
unsigned short16Unsigned integer
signed int16Signed integer
unsigned int16Unsigned integer
__int2424Signed integer
__uint2424Unsigned integer
signed long32Signed integer
unsigned long32Unsigned integer
signed long long32/64Signed integer
unsigned long long32/64Unsigned integer

The __bit and __int24 types are non-standard types available in this implementation. The long long types are 64-bit types when building for PIC18 or Enhanced Mid-range devices, but this implementation limits their size to only 32 bits for projects targeting any other device.

All integer values are represented in little-endian format with the Least Significant Byte (LSB) at the lower address.

If no signedness is specified in the type, then the type will be signed, except for plain char or __bit types, which by default have unsigned type (the concept of a signed bit is meaningless). It is recommended that you always specify the signedness of all integer types in your source code.

Signed values are stored as a two’s complement integer value.

The range of values capable of being held by these types is summarized in the declarations for <limits.h>, contained in the Microchip Unified Standard Library Reference Guide. The symbols presented there are preprocessor macros that are available after including <limits.h> in your source code. As the size of data types are not fully specified by the C 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. The macros associated with the __int24 type are non-standard macros available in this implementation. The values associated with the long long macros are dependent on the device being targeted.

Macros are also available in <stdint.h> which define values associated with exact-width types, such as int8_t, uint32_t etc.